0
votes

I've got the problem about crystal report. I've created one formula field called PAT_DEP and formula is as follow.

Local NUMBERVAR PAT_DEP_AMT := 0;

IF NextIsNull({MYOBJ.PAT_DEPOSIT}) = TRUE THEN
    (        
        IF {MYOBJ.PAT_DEPOSIT} = PREVIOUS({MYOBJ.PAT_DEPOSIT}) THEN
            (                
                PAT_DEP_AMT := 0;
            )

        ELSE
           (
                PAT_DEP_AMT  := {MYOBJ.PAT_DEPOSIT};
            );
    )
ELSE
    (
        IF PREVIOUS({MYOBJ.PAT_DEPOSIT}) = NEXT({MYOBJ.PAT_DEPOSIT}) THEN
            (
                PAT_DEP_AMT := ToNumber(0);
            )
        ELSE
            (
                PAT_DEP_AMT  := {MYOBJ.PAT_DEPOSIT};
            );
    )

Then I've created another formula field called TOT_PAT_DEP and formula is as follow like summarized above formula field.

TOTAL_PAT_DEP := SUM(@PAT_DEP)

But got crystal report error This field cannot be summarized crystal report error. Please help me how come I got this error.

1
Could you explain what you're trying to achieve with pat_dep? It looks a little like you maybe want a running total which evaluates on the change of a group?Lee Tickett
PAT_DEP will contain individual deposit amount of each patient. That's why I want to get subtotal and grandtotal from PAT_DEP.PPShein
why do you put a semicolon after the ) on the else part? and why do you only use it in some of them and not all?K09P

1 Answers

0
votes

Based on your explanation and formula, it looks like you have a one-to-many relationship which is causing you some difficulty. Let's take an example:

Order Table Order #, Total, Paid

Order Items Table Order #, Line #, Description

When you join the two tables you can no longer sum the total/paid columns because they will be multiplied by the number of order lines.

The way to overcome this is to create a group using the key. In my example you would group on Order #. You can then create a running total to sum the total/paid columns but will only evaluate on the change of your Order # group.

Does that make sense?