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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do the two summery calculation in crystal report

Status
Not open for further replies.

kate8

Programmer
Feb 14, 2001
184
US
Hi everyone,

I need create a crystal report. The report needs to select those records whose latest activity date minus second latest activity date great than 60 day. For example, a person has 10 activities in the database, if the most currently activity date is 11-13-2006, the second currently activity date is 08-01-2006. Then this person will be selected (from 08-01-2006 to 11-13-2006 is more than 60 days). I can use summary to select 1th largest or 2nd largest. But I do not know how I can do the calculation when I generate the report.

Is there any one have any idea about this problem?
Thank you for any ideas /suggestions!!!!!
 
First insert a group on {table.person} and then go to report->selection formula->GROUP and enter:

datediff("d",nthlargest(2,{table.date},{table.person}),nthlargest(1,{table.date},{table.person})) > 60

In the detail section, if you inserted Nthlargest(1) and Nthlargest(2) at the person group level, you could drag the results into the group header and suppress the detail sections. If you want to display the difference, then create a formula:

datediff("d",nthlargest(2,{table.date},{table.person}),nthlargest(1,{table.date},{table.person}))

...and add that to the group header.

-LB
 
lbass,

Thanks a lot!!! It works.
You save my day! Thank you!!!

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top