Skip to Content

crystal reports formula, output value incorrect

Dec 08, 2017 at 05:19 PM


avatar image

Hello All,

I am facing an issue.Though the formula doesnt show me any error but it does show the incorrect output value. I have a source column in that the data is "REC" and "PAY". I need to segregate the data "REC" and "PAY" then show the summary of that column


pay 12

pay 34

rec 23

rec 12

rec 5

pay 10

If source = "REC" then sum (gross) ::::: it should show the output as 40

if source = "PAY" then sum(gross) ::::: it should show the output as 56

is this the correct formula.? if yes i am not getting the right value in the output. Please help.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Brian Dong Dec 08, 2017 at 06:22 PM

Hi Paturi,

There are a couple of ways to do this. One way is to group your data by Source. Drop the Gross field into the Detail section and right-click it. Select Summary from the menu and select Sum. Make sure the sum goes into the Source GroupFooter.

This method will separate the source and summarize them separately.

The other more complicated way would be with running totals. It uses 3 formulas, one to initialize variables, one to accumulate the totals and the last to display the totals.

The following formula defines and initializes the variables. You can drop this into the ReportHeader Section.

NumberVar rec := 0; 
NumberVar pay := 0;

This formula accumulates the sum. Drop this into the Detail section.

NumberVar rec; 
NumberVar pay; 

Select {table.Source} 
     Case "REC": rec := rec + {table.GROSS} 
     Case "PAY": pay := pay + {table.GROSS} 
     Default: 0; 

This displays the total for REC. Drop this into the ReportFooter

NumberVar rec; 

This displays the total for PAY. Drop this into the ReportFooter.

NumberVar pay;

If you have groups, you can put the first formula into the GroupHeader and the two display formula into the GroupFooter. So the variables reset when the group changes and you can see the totals for that group.

Hope this helps,


10 |10000 characters needed characters left characters exceeded