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

Percent Increase of Subtotal fields

Status
Not open for further replies.

NewToCrystalX

Technical User
Feb 12, 2009
11
US
I am neew to the forum and a new to crystal reports.

I have a numeric field called AVERAGEFORCE.
I am pulling AVERAGEFORCE straight from a SQL table.
I group the data by DAY

I can show the daily percentage increase of Force by using the formula -
{data.AVERAGEFORCE}%(Previous({data.AVERAGEFORCE})

WORKS PERFECT...

The problem comes when I try to show percentage increase of the running total field of AVERAGEFORCE.

I try to use the same formula on the running total field #Force Rt -
{#Force Rt}%(previous({#Force Rt}))

I get the error "this field has no previous or next value"

I have tried using Evaluateafter... doesnt work.

Maybe it's impossible to use the PREVIOUS command on a formula filed?????

THANKS IN ADVANCE!!
 
How is the running total set up? You can't use previous with running totals, since running totals are based on a sequence of records. There is probably a different approach though. Please show some sample data that illustrates what you wanted the calculation to look like.

-LB
 
Thanks....

It's seems that this would be rather simple. But I have been pulling my hair out.

My subtotal field "GROUP AVERAGE FORCE" formula is -

Sum ({@Force Totals}, {data.timestamp}, "daily")/Sum ({@Sample Count}, {data.timestamp}, "daily")

This gives me my AVERAGE FORCE by DATE. I want to know the percentage of increase for each date.

I posted a PDF copy and the.rpt file itself @

Thanks
 
In the attached example then, do you mean to compare 7.00 with 17.53? If so, you can handle this with variables like this. Create a formula to place in GF2a:

whileprintingrecords;
numbervar curr;
numbervar prev := curr;
curr := {@Gr Ave Force};
(curr-prev) % prev

-LB
 
LB... Thanks so much for helping!

I created the formula and placed it in GF2a.

I get the error - "Division by zero"

Any idea?

Thanks again!

DD
 
LB,

I used the following and it works.

Thanks, I really appreciate it!!!!

whileprintingrecords;
numbervar curr;
numbervar prev := curr;
curr := {@Gr Avg Force};
if prev=0 then 0 else curr%(prev)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top