Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Records for Max Date

Status
Not open for further replies.

CappsRLO

Vendor
Apr 18, 2007
31
US
I have a table with 3 records
ID Date
1 10/8/2008
2 10/9/2009
3 10/9/2009

I need to generate a formula to count the number of records for the Max Date so my result should be '2' records for the date '10/9/2009'

Here is the formula I am using and it is not working. It is counting all 3:
If {DailyWork.Date}=Maximum(DailyWork.Date}) Then
Count({DailyWork.ID})
 
You can do it with Shared Variables.

In the report header put a formula like this:

//@init
shared datevar hidate := date(1900,1,1) ;
shared numbervar maxcnt :=0

in your detail section put a formula like this:
//@eval
shared datevar hidate ;
shared numbervar maxcnt ;
if {table.date} > hidate
then (hidate := {table.date} ; maxcnt :=1)
else if {table.date} = hidate
then (hidate := hidate ; maxcnt := maxcnt+1)
else (hidate := hidate ; maxcnt := maxcnt)

In you report footer goes one more formula:

//@show
shared numbervar maxcnt

 
This can be closed.
What I did was put in a Group Selection Formula:
DailyWork.Date=Maximum(DailyWork.Date)
I then put the DailyWork.ID in the Details and put a Running Total field Counting the DailyWork.ID
Not quite sure why I couldn't get it to work in a sys.formula field but this works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top