2 Replies Latest reply: Feb 11, 2013 3:14 PM by Dell Stinnett-Christy RSS

How to perform conditional count in SAP Crystal Report

Paul Aziz
Currently Being Moderated

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

  • Re: How to perform conditional count in SAP Crystal Report
    Abhilash Kumar
    Currently Being Moderated

    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

  • Re: How to perform conditional count in SAP Crystal Report
    Dell Stinnett-Christy
    Currently Being Moderated

    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

Actions