x
Solved

# how to code a percent change on a group summary?

Posted on 2008-10-07
Medium Priority
670 Views
I am reporting for a bank on deposit history.  I have the total deposits broken into the following groups:

Region
Deposit Group (ie ck, sav, cd, etc)
Date (I have selected records for end of month)

Total deposits are reported for each end of month period for each deposit group for each region by using a running summary on the detail level, which is the month end account balance of each account.  I would like to calculate a percent change on each period to graph.

A previous post on reporting percent change gave the following code:

shared numberVar LineCount;
LineCount := LineCount + 1;
If LineCount = 1 then
0
Else
(
if Previous({fieldname}) = 0 then
0
else
({fieldname}- Previous{fieldname})) / Previous({fieldname})
)

This code works if it is a database record, but it doesn't like the summary operation I am using.  It reports:

"This Field has no previous or next value."

Thanks for any assistance!
0
Question by:Rilken

LVL 101

Expert Comment

ID: 22665711
You can check if OnFirstRecord before using Previous.

Crsytal also has a PreviousIsNull test you can use.

mlmcc
0

LVL 35

Accepted Solution

James0628 earned 2000 total points
ID: 22674513
If you're saying that you're trying to use Previous () on a summary or running total, instead of on a field, then, as CR said, you can't do that.  Unless I'm mistaken, Previous () only works on fields in your datasource, or formulas that reference fields.  Assuming that I'm correct about what you're trying to do, I think you're going to have to do this another way.

You say that you have three groups and the last one is Date.  Is that your "period" group?  So, you're looking for the % change in some total for the Date (period) group, between one "period" and the next in the "Deposit Group" group?

If so, you'll probably need to use a formula in the Date group footer that will save the total at the end of each "period" in a variable and compare the current total to a variable containing the total from the previous "period" (if any).

You also mentioned that you wanted to graph the % change.  Do you want to do that in the report, or are you just trying to get the %'s on the report, and then you'll copy those and use them somewhere else to produce a graph?

James
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.