• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 589
  • Last Modified:

Crystal Reports Running Total in a Formula

Looking to find out how to write a formula that will calculate the running total of a field and reset on change of a group
0
nemesis1210
Asked:
nemesis1210
  • 5
  • 4
1 Solution
 
RPCITCommented:
You shouldn't actually have to use a formula unless you want to get fancy. (which sometimes happens)

You can use a RunningTotalField (should show up in your fields list, right click and hit new) .

The running total field allows you to change when you want to evaluate, and when you want to reset.
0
 
nemesis1210Author Commented:
unfortunatly I need to get fancy, I need to be able to run a calculation on two existing running totals and am unable to do so, so I am hoping to be able to create formulas for these as opposed to running total fields so I can perform my calculation.

Thanks anyhow
0
 
RPCITCommented:
You can manually create runnign totals, or "fancy" formulas by adding formula fields to the sections you want..

you could put the reset field in the group header, the increment field in the detail, and the display in the footer.

using something like this in the code:

//begin increase value;
WhilePrintingRecords;
numberVar SomeVal;
SomeVal := SomeVal + {tablName.FieldName}
//end
 
//begin reset value;
WhilePrintingRecords;
numberVar SomeVal;
SomeVal := 0;
//end
 
//begin display value;
numberVar SomeVal;
SomeVal
//end

Open in new window

0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
RPCITCommented:
missing semi-colon (;) on line 4
0
 
nemesis1210Author Commented:
almost there, values increase during the detail and reset at each group, however display is always zero in the footer
0
 
RPCITCommented:
try adding whileprintingrecords; at the top of the display formula
0
 
nemesis1210Author Commented:
Perfect thank you
0
 
nemesis1210Author Commented:
Worked like a champ
0
 
RPCITCommented:
You welcome :)
0
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.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now