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

% of each record used in running total

Status
Not open for further replies.

adubrovs

Technical User
Feb 24, 2011
23
CA
I've created a running total using the 3 formula method to get a sum of a number of records. Is it possible to then calculate the % of each record of the running total?

The obvious issue is that Crystal evaluates each row at a time to generate the running total, so when I try to calculate the %, it performs the calculation at the sum of specific row it's at and not at the grand total.

Example.

GF2 - 1
GF2 - 3
GF1 - 4 (total)

GF1 is where my display variable is that is summing up GF2 details.
Now i need a column that shows the GF2 as % of GF1.

Thanks.
 
You could change it to a summary total. These are non-selecting, but you can create a detail-line formula and then total that, e.g.
[Code @Sumthis]if {Your.Field} = "Fine" then {Amount} else zero.[/code]

Then add a detail line formula to check the amount as a percentage of the summary total, where the amount qualifies.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Sorry, can you please elaborate as to what {Your.Field} and {Amount} are as they relate to my example?
 
Please explain WHY you are using a running total, and explain in what report sections you have placed each of the three formulas. Please also show the content of the accumulation formula.

-LB
 
Basically the need for the 3 formula method is because i need to sum values based on a group to get the values which are then summed for a grand total.

The accumulation formula is placed in the GF2. Reset is in GH1 and Display in in GF1.

The content of accumulation is:

WhilePrintingRecords;
Shared numbervar TotalMV;
TotalMV := TotalMV + {@CDN Value}

 
And the content of {@CDN Value}? And of any formulas nested within it?

I'm just wondering whether the running totals are really necessary--in other words, is it the case that the sum of the value field in the details section at the group 1 level is not the same as the sum of the group 2 values?

If they are unequal, then you could save the current report as a subreport and insert it into GF2_a and link it on the GF#1 field only. Then add a shared variable in the sub to pass the sum to the GF2b section, where you can do the percentage calculation using the shared variable.

-LB
 
your idea of using the subreport to pass the sum to the main report worked great.

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top