Skip to Content
0
Feb 03, 2023 at 08:31 PM

Percentage Difference Year to Year

33 Views

I have a report where there are annual counts. The formulas I have to determine the percentage change between each year, and compared to the base year are off. The variance is from .3 to .9 and I cannot figure out why. Here are the four formulas in play to determine the percentages.

FirstGroupName

Global StringVar FirstGroupName := IF GroupNumber = 1 THEN GroupName ({@IncidentYear}) else FirstGroupName;


IncidentYear

Year ({lwmain.dtrepor})

PercentChange

Global NumberVar PrevYear := IF GroupNumber = 1 THEN count ({lwmain.number}, {@IncidentYear}) ELSE PrevYear;

Global NumberVar CurrYear := count ({lwmain.number}, {@IncidentYear});

Local NumberVar PercentDiff := IF PrevYear = CurrYear or PrevYear = 0 THEN 0 ELSE ((CurrYear - PrevYear) / PrevYear * 100);

PrevYear := count ({lwmain.number}, {@IncidentYear});

PercentDiff

PercentChangeFrom1stGroup

Global NumberVar FirstYear := IF GroupNumber = 1 THEN count ({lwmain.number}, {@IncidentYear}) else FirstYear;

Global NumberVar CompareYear := count ({lwmain.number}, {@IncidentYear});

Local NumberVar PercentDiff := IF FirstYear = CompareYear or FirstYear = 0 THEN 0 ELSE ((CompareYear - FirstYear) / FirstYear * 100);

PercentDiff