I am trying to create a formula for calculating the percentage difference between two running totals. In my report, I have grouped months by Quarter and have created a running total for each quarter. What I need to do now is to add a row for comparing the totals of each quarter using the following formulas:
(Current Quarter - Previous Quarter)/Previous Quarter
Anyway, I was looking at using global variables in order to achieve this. The Crystal Reports formula I have is below. However, when I try to save it I get the following message:
The remaining text does not appear to be part of the formula ( everything after the IF statements is highlighted )
Basically, my goal is to use a global variable to store the previous groups running total in order to calculate the comparisons I need. I was just wondering if this is the correct way to achieve what I need to do or is there a better way? Also, would appreciate any help in fixing the formula posted below.
thanks
Global NumberVar previousTotal;
previousTotal := 0;
WhilePrintingRecords;
if ( previousTotal > 0 )
then (({#Quarter Total}-previousTotal)/previousTotal)
else
0 ;
previousTotal :=({#Quarter Total});
Best Answer
Your formula is not returning anything. You need to move some things around in order to get it to work: