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!

Summing an IF statement 1

Status
Not open for further replies.

Fin13

Technical User
Mar 29, 2004
4
US
I am having trouble figuring out how to summarize an IF statement at the group level within Crystal 8.5. I have created a report that sums reject qty by reject code(group1) then by part number(group2) for a date range. Next I created an IF statement in the details section stating:

If(defects.shiftdate} = maximum({defects.shiftdate}) then {defects.quantity} else 0

this returns only quanitities for the maximum date at the detail level. How do I then sum this info at the Group Levels?

Thanks for your help!
 
Hi,
What have you tried?

Does using Right-Click on the Field..Insert..Summary option not give you what you want?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
No, there is no Insert option on the Right Click menu. I've tried doing a few things with running totals as well, but again, I couldn't get it to sum correctly at the group levels.
 
Have you tried evaluating the running totals based on a formula? If so what error are you getting and/or what unexpected results are you getting?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Are you looking for the maximum per part number group? Then your formula (let's call it {@maxdateqty}) should be:

If(defects.shiftdate} = maximum({defects.shiftdate},{table.partno}) then {defects.quantity} else 0

Then you could summarize these results at the group levels and report level by using variables:

//{@resetptno} to be placed in the part number group header:

whileprintingrecords;
numbervar partnoqty;
if not inrepeatedgroupheader then
partnoqty := 0;

//{@resetrejcodeqty} to be placed in the reject code group header:

whileprintingrecords;
numbervar rejcodeqty;
if not inrepeatedgroupheader then
rejcodeqty := 0:

//{@accum} to be placed in the detail section:
whileprintingrecords;
numbervar partnoqty := partnoqty + {@maxdateqty};
numbervar rejcodeqty := rejcodeqty + {@maxdateqty};
numbervar grtotptnoqty := grtotptnoqty + {@maxdateqty};
numbervar grtotrejcodeqty := grtotrejcodeqty + {@maxdateqty};

//{@displptnoqty} to be placed in the part number group footer:

whileprintingrecords;
numbervar partnoqty;

//{@displrejcodeqty} to be placed in the reject code group footer:
whileprintingrecords;
numbervar rejcodeqty;

//{@displgrtotptno} to be placed in the report footer:
whileprintingrecords;
numbervar grtotptnoqty;

//{@displgrtotrejcode} to be placed in the report footer:
whileprintingrecords;
numbervar grtotrejcodeqty;

-LB
 
Well, it looks like I finally figured it out! Kinda feel stupid now, but guess I didn't fully understand how Running Totals worked. My running total formula was right all along, I just kept trying to sum it in the Group Header rather than the Group Footer, thinking the same result would appear just like a normal sum function. Once I through the running total in the Group Footer...viola. Anyway, thank you very much for your replies and help!

 
Lbass you are awesome! Hadn't seen your post before I posted my reply. Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top