0

I'm using Crystal Reports. I want to count all cells having "Yes" and all cells having "No" for each line as in following image:

Example Image

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

2 Answers2

0

You'll need to count it using custom formulas. Create formula fields in report design, namely ff_Evaluate, ff_Yes, ff_No and set their values in formula editor like this:

  1. ff_Evaluate (check each column and add to yes or no var)

    WhilePrintingRecords;
    numberVar YesCount := 0;
    numberVar NoCount := 0;
    
    if {table.T0} = "Yes" then
        YesCount := YesCount + 1
    else if {table.T0} = "No" then
        NoCount := NoCount + 1;
    
    if {table.T1} = "Yes" then
        YesCount := YesCount + 1
    else if {table.T1} = "No" then
        NoCount := NoCount + 1;
    ...
    ...
    if {table.Tn} = "Yes" then
        YesCount := YesCount + 1
    else if {table.Tn} = "No" then
        NoCount := NoCount + 1;
    
  2. ff_Yes

    WhilePrintingRecords;
    EvaluateAfter ({@ff_Evaluate});
    numberVar YesCount;
    
  3. ff_No

    WhilePrintingRecords;
    EvaluateAfter ({@ff_Evaluate});
    numberVar NoCount;
    

Now place these formula fields in your Details section and Suppress ff_Evaluate by Right Click on it, point to Format Field and then in the Common tab select Suppress

haraman
  • 2,744
  • 2
  • 27
  • 50
0

Assuming columns named T0, T1, T2, T3, T4. Increase as necessary.

Create a formula (TOTAL), place it in the Details section (suppress it, if desired):

// create an array to contain the fields' values
Local Stringvar Array values := [{Command.T0},{Command.T1},{Command.T2},{Command.T3},{Command.T4}];

// global variables to contain tallies
Numbervar Y:=0;
Numbervar N:=0;

// generate tallies
Local Numbervar i;
For i:=1 To Ubound(values) Do (
    select values[i]
    case 'Y': Y:=Y+1
    case 'N': N:=N+1
)
;

Create a formula (Y), place it in the Details section:

// display Y after tallies have been generated
EvaluateAfter({@TOTAL});
Numbervar Y;

Create a formula (N), place it in the Details section:

// display N after tallies have been generated
EvaluateAfter({@TOTAL});
Numbervar N;

If necessary, you may use a summary field to total each value.

craig
  • 25,664
  • 27
  • 119
  • 205