Roger,
Thanks for your advice. I tried your program and have two issues in my
application.
1. If any record is null, the median calculation fails to work. Is there
any way to get round it under this situation.
2. I put it =DMedian97("qryLeadtime","Leadtime","Category") in the
control source of a text box under the group footer of a report and returned
incorrect result plus error message saying "Item not found in this
collection.". If I change the where clause to [Category]=ABC, it works
correctly. I cannot use it like that since I group Category in the
report
and would like to get the median in each group.
Your further advice is appreciated.
Thanks,
Scott
The median function in the article does not make any provision for
grouping.
It finds the median of the entire dataset.
My function has a Where clause argument. If you put the field you are
grouping by in that argument, then you will get a Median for that
group.
--
--Roger Carlson
MS Access MVP
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Roger,
I got the code from Microsoft on article ID 210581. It works
correctly
and
I tried it without grouping. I have no idea how to apply it in grouping
on
a report. I believe my issue is similar to how to sum a field of records
in
a group instead of whole recordset.
Scott
To my knowledge, Access does not have a built-in Median function.
Where
did
you get this? What version of Access?
On my website (
www.rogersaccesslibrary.com), is a small Access database
sample called "Median.mdb" which illustrates how to create your own
Domain
Aggregate function called DMedian, which will allow you to specify a
Where
condition so you can aggregate on groups.
--
--Roger Carlson
MS Access MVP
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
I would like to find the medians in each group rather than in
total.
Category
Leadtime
Overallleadtime
Record1
Record2
.
.
.
.
Record20
Group footer Median("qryName","Leadtime")
Median('qryName","Overallleadtime")
It just returns the medians of all records, not the records of each
group.
Your advice is appreciated.
Thanks,
Scott