Print Page | Close Window

Addition In Crystal Report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17641
Printed Date: 02 May 2024 at 1:26pm


Topic: Addition In Crystal Report
Posted By: Ganesh050
Subject: Addition In Crystal Report
Date Posted: 27 Sep 2012 at 1:48am
pls i need help regarding crystal report pls help me out asap
i have one column there r some values i want to calculate another column in that display the first row value would be 0 and then start cross addition in crystal report how i show that for that what i do i dont want to calculate running total sum i want to write formula for that which function should i use for calculating addition in crystal report
for example i have following column in crystal report

          Column 1                      Output
              21                               0
              48                             21
              56                             69
               0                             125
               0                             125


i want an output given in Output Column:

I can get the above ans by using running total but i dont want to use running total as i want to write formula based on the result.
Kindly help me with this asap.


Thanx
Ganesh



Replies:
Posted By: lockwelle
Date Posted: 03 Oct 2012 at 4:39am
shared variables will do the same as running total but you do all the work in formulas. usually in groups of 3, reset, increment, display, start with the easiest:
reset (usually in a group header)
shared numbervar x;
x:=0;
""  // will hide the reset
 
increment (usually in details)
shared numbervar x;
if some condition then
 x := x + {table.field};
"" //again hides the increment from displaying on the report.
 
display (usually in a group footer)
shared numbervar x;
x
 
HTH


Posted By: Ganesh050
Date Posted: 03 Oct 2012 at 6:40pm
above given formula is not working pls give me another formula for the same output


Posted By: lockwelle
Date Posted: 04 Oct 2012 at 4:29am
it's a sample to follow...it is not working since I have no clue as to your data or your logic.


Posted By: hilfy
Date Posted: 10 Dec 2012 at 9:34am
Why can't you use a running total?  Is this some sort of class assignment?
An alternative to lockwelle's approach is to do it all in one formula without the separate reset formula.  It would look something like this:
 
NumberVar sumTotal;
 
if PreviousIsNull({table.group_field}) or {table.group_field} <> Previous({table.group_field}) then
 sumTotal := 0
else
 sumTotal := sumTotal + {table.Column1}
 
This sets the value to 0 at the beginning of the report and whenever the group you're adding values for changes.  If you don't have a group, take out the "or {table.group_field} <> Previous({table.group_field}) "
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window