cancel
Showing results for 
Search instead for 
Did you mean: 

CR XI R2 - Sum columns at end of row

Former Member
0 Kudos

I have a table with 3 columns and I'm trying to sum the results of the 3 in the 4th column. But I'm confused as to how many formulas I need and where they go.

Putting the formula below in the Column 4 Details give a result that is only counting Column 3. I'm not sure if this is supposed to be running total.

Group Header: Col 1 Col 2 Col 3 Col 4 ____ Details: Text1 Text2 Text3 ColumnSum

My calculation formula (Crystal syntax):

WhilePrintingRecords;
numbervar x;
numbervar y;
numbervar z;
numbervar ColumnSum;
ColumnSum:= x + y + z ;

if {@Text1}="N/A" then ( numbervar x := 0 ; ) else if {@Text1}="Low" then ( numbervar x := 1 ; )...etc.  ;
if {@Text2}="N/A" then ( numbervar y := 0 ; ) else if {@Text2}="Low" then ( numbervar y := 1 ; )...etc.  ;
if {@Text3}="N/A" then ( numbervar z := 0 ; ) else if {@Text3}="Low" then ( numbervar z := 1 ; )...etc. 

Thanks in advance for any help

Edited by: GenePoz on Jun 24, 2010 11:57 PM

Edited by: GenePoz on Jun 25, 2010 12:02 AM

Accepted Solutions (1)

Accepted Solutions (1)

former_member292966
Active Contributor
0 Kudos

Hi Gene,

If this is on the Detail section then you don't really need a running total but you will need the variables. Try this:

numbervar x;
numbervar y;
numbervar z;
numbervar ColumnSum;
ColumnSum:= x + y + z ;
 
if {@Text1}="N/A" then ( x := 0 ; ) else if {@Text1}="N/A" then ( x := 1 ; )...etc.  ;
if {@Text2}="N/A" then ( y := 0 ; ) else if {@Text2}="N/A" then ( y := 1 ; )...etc.  ;
if {@Text3}="N/A" then ( z := 0 ; ) else if {@Text3}="N/A" then ( z := 1 ; )...etc. ; 

x + y +z;

The reason it only shows column 3 is because that's the last thing the formula evaluates. You need to tell have the formula sum the 3 columns.

Good luck,

Brian

Former Member
0 Kudos

Thank you so-o-o much, Brian.

Answers (0)