Skip to Content

crystal reports formula, output value incorrect

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on 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,


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.