Problem with SUM function
Author Message Problem with SUM function

I'm using Crystal Report 5

I have a report with subreports on it.  In one of the subreports I
have a Grand Total in the report footer section.

To create this Grand Total, I click on the right button when I'm on
the field I want to sum in the detail section, and I choose "Insert
Grand Total" option.

But here's the problem. If the field from wich I want to add a Grand
Total consist of a formula, everyting works fine, but if I write an IF
THEN ELSE statement, the "Insert Grand Total" option is no longer
avaible.

---------------------------------------------------------------------------
e.g.

If there is one formula in the detail section.

formula 1.     (right click and the Insert Grand Total option appear)

---------------------------------------------------------------------------

If there is an IF THE ELSE statement

if condition then
formula 1
else
formula 2

If I right click on the field, the Insert Grand Total option does not
apear.

Fri, 28 Apr 2000 03:00:00 GMT  Problem with SUM function

Hi, Michel.

The Sum function won't work on some (most) formulas.  You should create some
formulas of your own to calculate the totals.  Have a look in your Help file
for Running Totals.  It gives an example of how to set it up.

Jonathan

Quote:

>I'm using Crystal Report 5

>I have a report with subreports on it.  In one of the subreports I
>have a Grand Total in the report footer section.

>To create this Grand Total, I click on the right button when I'm on
>the field I want to sum in the detail section, and I choose "Insert
>Grand Total" option.

>But here's the problem. If the field from wich I want to add a Grand
>Total consist of a formula, everyting works fine, but if I write an IF
>THEN ELSE statement, the "Insert Grand Total" option is no longer
>avaible.

>---------------------------------------------------------------------------
>e.g.

>If there is one formula in the detail section.

>formula 1.     (right click and the Insert Grand Total option appear)

>---------------------------------------------------------------------------

>If there is an IF THE ELSE statement

>if condition then
>  formula 1
>else
> formula 2

>If I right click on the field, the Insert Grand Total option does not
>apear.

Fri, 28 Apr 2000 03:00:00 GMT  Problem with SUM function

Does both the If and the Else evaluate to a numeic? If not you will not be
able to sum it. This is usually the cause. i.e
If bla then
5
else
"A";
you cannot sum the above even if bla is always true.

Sat, 29 Apr 2000 03:00:00 GMT  Problem with SUM function

Both of the If and the Else evaluate a numeric.

Quote:
>Does both the If and the Else evaluate to a numeic? If not you will not be
>able to sum it. This is usually the cause. i.e
>If bla then
>  5
>else
>  "A";
>you cannot sum the above even if bla is always true.

Sun, 30 Apr 2000 03:00:00 GMT  Problem with SUM function

The problem stems from the way crystal evaluates formulas in the two
passes over the data.  The first pass reads the records and basically
does nothing else.  The second pass is when any if-then-else statements
are evaluated.  The problem is that the built in sum functions also
occur in the second pass which results in a conflict.  Doing things this
way requires that the sum function occur on the third pass so that it
can some the results of the if-then-else formulas from the second pass.
Unfortunately, crystal doesn't do a third pass.  Using the directives
'WhilePrintingRecords' doesn't help in this situation either.

The answer is to use variables to calculate totals for you.  This is
slightly more complicated but it allows you to sum the data in the two
passes that crystal allows.  You must use the directive
'WhilePrintingRecords' when you work with variables for running totals.
This will save you many headaches.  Using the variables for running
totals allows you to evaluate your if-then-else statements in the second
pass, and it also allows you to manipulate and display variables in the
second pass.  For example you could initiate a variable in a group
header, then manipulate this variable in the details section using an
if-else condition, and then finally display the variable value in the
group footer.  The crystal manual provides some elementary discussion of
this issue, but you really need to work with it in order to see it's
true "power".  I use the term mildly.

I am hoping that crystal 6 will solve all of my problems.  :-)

Quote:

> Both of the If and the Else evaluate a numeric.

> >Does both the If and the Else evaluate to a numeic? If not you will not be
> >able to sum it. This is usually the cause. i.e
> >If bla then
> >  5
> >else
> >  "A";
> >you cannot sum the above even if bla is always true.

Tue, 02 May 2000 03:00:00 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages