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

Summing the MAXIMUM function

Status
Not open for further replies.

lisa626

Programmer
Joined
Aug 9, 2006
Messages
92
Location
US
Is there a way in Crystal XI to sum the MAXIMUM function, I have a report with several groups and I need to use maximum to get the correct number at group 2 then need to sum that to get a total in group 1.

EX.

Group 1 3 REDGO@ + HEUDYE + EKRKEK
Group 2 REDGO@ 1
Detail 1254789658 1

Group 2 HEUDYE 1
Detail 1254789658 1

Group 2 EKRKEK 1
Detail 1254789658 1
4587986589 1

 
In your example, all you really need to do is insert a distinct count of your group #2 field at the Group #1 level and then drag it into the Group #1 header.

If you example doesn't reflect your actual needs, then you could use a variable to sum the maximums, but the result would have to be displayed in the group #1 footer, not header. You would create these formulas:

//{@reset} to be placed in GH1:
whileprintingrecords;
numbervar summax;
if not inrepeatedgroupheader then
summax := 0;

//{@accum} to be placed in the group #2 header or footer:
whileprintingrecords;
numbervar summax := summax + maximum({table.amt},{table.grp2field});

//{@display} to be placed in the group #1 footer:
whileprintingrecords;
numbervar summax;

-LB
 
My fault I wasn't 100% clear,

Group 1 ABC
Group 2 BAAAME NON REFUNDABLE
Detail 132456 640.20 1 0

BAAADG NON REFUNDABLE
123654 246.04 1 0

BAABFP REFUNDABLE
458975 326.60 0 1

CDEFJJ REFUNDABLE
987589 1.00 0 1

UEIRRU NON REFUNDABLE
458796 711.54 1 0
987541 336.27 1 0

I need to show that there are 3 NR tickets with a total price of 1934.05 and 2 R tickets with a total price of 327.60. I can get the formula for the prices down, that is working. What I am having trouble with is I can't get it to show 3 NR, it keeps showing 4, technically there are 4 but I want it to show 3 cause i need it to sum at the group level 1 and count the two tickets under UEIRRU as 1.

I tried your 3 formulas and they kept returning 1.

 
I don't think you implemented my solution correctly. I'm guessing you didn't use the correct formula for {@accum}. You might want to recheck that. My earlier suggestion would work, or here's another one.

Create a formula {@null} by opening a new formula and then saving and closing it without entering anything. Then create a second formula {@nr}:

if {table.status} = "NON-REFUNDABLE" then {table.group2field} else {@null}

Then right click on {@nr} in the detail section and insert a distinctcount on it at the Group #1 level.

It would help in future posts if you provided the names of your fields and the datatypes.

-LB
 
Ok, here is my field names/data types.

Group 1 ABC {@Bus Unit} (formula) ((if left({TICKETS.DIVISION},1)="1"
then "CORP"
else if left({TICKETS.DIVISION},1)="2"
then "SSG"
else if left({TICKETS.DIVISION},1)="4"
then "BCA"
else if left({TICKETS.DIVISION},1)="8"
then "PW"
else if left({TICKETS.DIVISION},1)="9"
then "IDS"
else if left({TICKETS.DIVISION},1)="B"
then "BCC"
else if left({TICKETS.DIVISION},1)="C"
then "CBB"
else if left({TICKETS.DIVISION},1)="D"
then "IBP"))

Group 3 BAAAME {TICKETS.PNR_LOCATOR} NON REFUNDABLE{@Tkt Type} (formula) ((If {TICKETS.SAVINGS_CODE} = "NR"
then "Non Refundable"
else "Refundable"))
Detail 132456 {TICKETS.TICKET_NO} 640.20 {TICKETS.TOTAL_FARE) 1 {@NR Tickets} (Formula) ((if {@Tkt Type}="Non Refundable"
then 1)) 0 {@R Tickets} (Formula) ((if {TICKETS.SAVINGS_CODE}<>"NR"
then if {TICKETS.SAVINGS_CODE}<>"PX"
then 1))

BAAADG NON REFUNDABLE
123654 246.04 1 0

BAABFP REFUNDABLE
458975 326.60 0 1

CDEFJJ REFUNDABLE
987589 1.00 0 1

UEIRRU NON REFUNDABLE
458796 711.54 1 0
987541 336.27 1 0


I hope this helps cause if not I am lost, in the accum and the above sample I guess I am confused on which fields I need to be putting where. Again, THANKS.
 
Please try my last suggestion and provide feedback.

-LB
 
You are AWESOME, thank you SOOOOOOOO MUCH!!
 
OK, New But VERY similar.

I know need to show how many changes occurred on Non Refundable tickets and Refundable tickets, following is how data is seen.

Group 1 ABC
Group 2 BAAAME NON REFUNDABLE
Detail 132456 640.20 NR 1 0

BAAADG NON REFUNDABLE
123654 246.04 NR 1 0

CDEFJJ REFUNDABLE
987589 1.00 R 0 1
987591 123.00 PX 0 1

UEIRRU NON REFUNDABLE
458796 711.54 NR 1 0
987541 336.27 PX 1 0

Ok, the PX represents a "CHANGE" ticket, so I need to first see how many changes occur at the group 2 level then i need to see it at the group 1 level, end result should look like...

Div Name 5 3 1 1 1
Total Rec NR Rec NRP Rec R Rec RP Rec


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top