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

Total % formula

Status
Not open for further replies.

ChrisH1

IS-IT--Management
Joined
May 23, 2006
Messages
36
Location
GB

Im trying to write a formula that will generate a total profit %.

In the GF I have used the following :

if sum ({@Work Done},{JCPERTOT.COMPANY}) = 0
then 0
else
(sum({@Profit Multi},{JCPERTOT.COMPANY})/sum({@Work Done},{JCPERTOT.COMPANY}))*100

I now want to do a grand total profit percentage also in the gf, I tried the following but it tells me Im missing a (.

if sum (Sum ({@GRAND}, {JCPERTOT.COMPANY}) = 0
then 0
else
(sum(Sum ({@Grand Profit },{JCPERTOT.COMPANY})/sum(Sum ({@GRAND},{JCPERTOT.COMPANY}))*100

If anyone can point me in the right direction it would be greatly appreciated.

Thanks

Chris

 
I'd have thought
(Sum ({@GRAND}, {JCPERTOT.COMPANY}) should be
(Sum ({@GRAND}, {JCPERTOT.COMPANY})), even though you said it was an open-bracket that was missing.

Take a look at Running Totals, they will do the work for you. Also it helps to give your Crystal version.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I'm not sure about your logic--do you really need the sum of your current percentages, or do you need to do the same calculation at the report level?

For the latter, you would just change your formula to:

if sum ({@Work Done}) = 0
then 0
else
sum({@Profit Multi})/sum({@Work Done})*100

If you really need to add the percentages, then use two formulas:

//{@accum} to be placed in the GF:
whileprintingrecords;
numbervar sumpercent := sumpercent + {@yourGFformula};

//{@displ} to be placed in the report footer:
whileprintingrecords;
numbervar sumpercent;

-LB
 

Thanks, I think I over complicated the formula as the following seems to work fine

Sum ({@Grand Profit }, {JCPERTOT.COMPANY})/Sum ({@GRAND}, {JCPERTOT.COMPANY})*100
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top