cancel
Showing results for 
Search instead for 
Did you mean: 

How to perform conditional count in SAP Crystal Report

paul_aziz
Explorer
0 Kudos

I am using SAP Crystal  for VS 2010 to generate report.  I have a Boolean field named Status in the report that indicate whether a person was present or not .

I want to know whether it is possible to get the number of times a person was present/absent and how it can be implemented. In other words, I want to be able to indicate the number of Yes/No or 1/0 for a person

Any assistance would greatly appreciated.

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Paul,

Assuming the report is grouped on 'Person', here's what you can do:

whileprintingrecords;

numbervar present;

numbervar absent;

booleanvar Status;

if Status = 1 then

     present := present + 1

else if Status = 0 then

     absent := absent + 1;

Place this formula field on the report beside the Status variable and suppress it.

Next, create this formula to count the no. of times the person was present/absent. Place this formula on the Group Footer:

whileprintingrecords;

numbervar present;

numbervar absent;

"This person was Present :"&present&" time/s"&chr(13)&

" and Absent :"&absent&" time/s"

Lastly, create a formula to reset the variables and place it on the Group Header. You may keep this field suppressed.

whileprintingrecords;

numbervar present := 0;

numbervar absent := 0;

Let me know how this goes!

-Abhilash

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Kudos

You can also do this without the variables....  You would create two formulas that look like this:

{@IsPresent}

if status = 1 then 1 else 0

{@IsAbsent}

if status = 0 then 1 else 0

You then sum these formulas to get the count of present and absent.

-Dell