ACC: How to Create a Top Values Per Group ReportID: Q132056
|
Novice: Requires knowledge of the user interface on single-user computers.
This article demonstrates how you can create a report that ranks a specific
number of records for each group in order according to a top value, for
example, the top five selling products per category.
NOTE: This article explains a technique demonstrated in the sample
files, RptSampl.exe (for Microsoft Access for Windows 95 version 7.0)
and RptSmp97.exe (for Microsoft Access 97). For information about how
to obtain these sample files, please see the following articles in the
Microsoft Knowledge Base:
Q145777 ACC95: Microsoft Access Sample Reports Available on MSL
Q175072 ACC97: Microsoft Access 97 Sample Reports Available on MSL
Microsoft Access has a TopValues property that you can use in a query to
return a specific number (N) or a specified percentage (N%) of records.
Using a main/sub report with a query that has a value set for its TopValues
property, you can create a report listing the top N records for each group.
To create a top values per group report, follow these steps:
Query: Top_N_Products
----------------------------------------------------------
Type: Select Query
Join: Order Details.[ProductID] <-> Products.[ProductID]
TopValues: 5
NOTE: In version 2.0, type a space in the Product ID field.
Field: CategoryID
Table: Products
Total: Group By
Criteria: [Reports]![Top_N_Per_Group]![CategoryID]
NOTE: In version 2.0, type a space in the Category ID field.
Field: ProductName
Table: Products
Total: Group By
NOTE: In version 2.0, there is a space in the Product Name field.
Field: SaleAmount: Sum([Order Details].[UnitPrice]*[Quantity])
Total: Expression
Sort: Descending
NOTE: In version 2.0, type a space in the Unit Price field.
NOTE: Referencing the CategoryID from the Top_N_Per_Group report
as criteria ensures that this query filters records by CategoryID
before it applies the TopValues property to the recordset.
For more information about the TopValues property, search the Help Index for "TopValues Property," or ask the Microsoft Access 97 Office Assistant.
Keywords : kbusage RptOthr
Version : 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 20, 1999