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

Finding the maximum of a formula 1

Status
Not open for further replies.

RobbieB

Technical User
Apr 25, 2003
215
US
I have created two running totals #RTotal0 finding the minimum date in a group and #RTotal1 finding the maximum date in the group. Then I created a formula called "days" which looks like this - DateDiff ("D",{#RTotal0} , {#RTotal1}) + 1. This is to calculate how many days it took a customer to use a multi day ski ticket. Now I would like to find the maximum of the "days" formula to see the longest anyone took to use their multi day ticket. I know you can't summarize a formula and you can't make an array based on a formula so, I was hoping someone here would have a bright idea for me.I would want the Max of @days to be in the group footer below the group @days is in.

The report is set up like this:
GRPH 1 Items long description
Grp 2 Access Number (the number assigned to a ticket)
Details (suppressed)
GRPF 1 #RTotal0 #RTotal1 and @Days
GRPF 2 Where I would like max of @Days to be located.

I hope this makes sense. I am running Crystal V.9 on a windows XP Pro machine.

Thanks in advance
 
Use the Report/Top N to find the largest.

-LW
 
You can make an array based on a formula.

The Top N should handle this though. Consider using conventional summaries as opposed to Running Totals.

-k

 
Unless 9.0 adds new features, I don't think topN can be used with this particular formula, since it contains running totals. Instead of using running totals, create a formula like {@daysdiff} to be placed in the Group #2 footer (you have your group footers labeled backwards above--I am assuming that Group#2 is on {table.accessno}, and that Group#1 is on {table.items}):

//{@daysdiff} to be placed in the Group #2 footer:
datediff("d",minimum({table.date},{table.accessno}),maximum({table.date},{table.accessno}))

Then create the following formulas:

//{@reset} to be placed in the Group #1 header:
whileprintingrecords;
numbervar max := 0;

//{@accum} to be placed in the Group#2 footer:
whileprintingrecords;
numbervar max;

if {@daysdiff} > max then
max := {@daysdiff} else
max := max;

//{@displaymax} to be placed in the Group#1 footer:
whileprintingrecords;
numbervar max;

-LB
 
LB that's a great idea. I had to change this formula
//{@daysdiff} to be placed in the Group #2 footer:
datediff("d",minimum({table.date},{table.accessno}),maximum({table.date},{table.accessno}))

to this: whileprintingrecords;
numbervar DD;
DD :=
datediff("d",({#RTotal0}),
({#RTotal1})) + 1

Otherwise I was getting the number of days for the whole season not just for the maximum days for each item type. (GRPH 1 Items long description)
Thanks for the input though. I started down this track once but never finished the thought and abandoned it.
Thanks again, Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top