ACC: Reporting the Median Value of a Group of RecordsID: Q103271
|
Novice: Requires knowledge of the user interface on single-user computers.
This article demonstrates how to create a report that shows the median
value for a set of records. Note that a median value is the midpoint
in an ordered set of values (the value above and below which there is
an equal set of values), or the arithmetic mean of the two middle
numbers if there is no one middle number.
The following sample report is based on the Orders table in the sample
database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0). The report
will group records by the CustomerID field, and will sort records within
each group by the Freight field.
NOTE: In Microsoft Access 1.x and 2.0, there is a space in the Customer ID
field name.
Name Control Source
-------------------------------
IDCount =Count(*)
Half =Int([IDCount]/2)
Odd =([IDCount] Mod 2)
Name Control Source
-------------------------------------------------------------
Position =1
Arg1 =Val(IIf([Position]=([Half]+[Odd]),[Freight],0))
Arg2: =Val(IIf([Odd]=0,IIf([Position]=([Half]+_
[Odd]+1),[Freight],0),0))
Name Control Source
--------------------------------------------------
Median =IIF([Odd]=0,([Arg1]+[Arg2])/2,[Arg1])
Keywords : kbusage RptOthr
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 26, 1999