Search code examples
crystal-reportsformula

Crystal Reports: Trying to use result from one formula in another formula


Using Crystal V14 if needed.

On Details A line, I am trying to show a starting amount

On Details B line, there needs to be a running total. So the first amount of -$238,000 should show the result of it being taken off the start, then the following amounts should show the amount resulting from the previous result. So the first one on Details B should be 258,567,000, then the next should be 258,329,000 and so on.

I have 3 formulas set up. One on Details A to only show the starting amount (@Notional), then two on Details B: one to grab the amounts to be taken off the starting amount (@NotionalSum), and another to add them both together (@NotionalRunning)

These are:

Details A:

Notional

if {events.comments}='Notional' then {events.amount}

Suppression on Details A: {@notional} <= $0.00

Detail B:

NotionalRunning

{@Notional}+{@notionalsum}

NotionalSum

if {events.comments} = 'Repay Notional' then {events.amount}

Suppression on Detail B: {@notionalsum} = $0.00 or {events.comments} <> 'repay notional'

How it appears in the report:

enter image description here

enter image description here

As you can see it is not calculating like I want it to. I have found that the result from Notional is not passing to NotionalRunning. I tested this by just putting {@Notional} into the NotionalRunning formula and it shows $0.00.

Any assistance with this would be great. I tried inserting a Running Total, but I just don't understand enough of how they work to get it to work. Everything I did try, failed.

Thanks


Solution

  • You are not incrementing, totalling, or summing anything, so Crystal simply displays the values associated with whatever detail row you are displaying.

    For the running total, one option is to declare a variable and accumulate the values into that variable. But it would be easier to simply use the built-in Running Total field option. right click that node and set the options you need.

    Create Running Total

    In your case, in the 'Evaluate' area of the dialog, you would use a formula ({events.comments} = 'Repay Notional') to impose a condition on the evaluation of the running total.

    Impose an Evaluation Condition

    It's not clear what you intend the Sum to total. But, again, you probably need to move from displaying a row-level expression to displaying a real total.