Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1344
  • Last Modified:

Create a conditional summary using Crystal Reports

i have a dataset with a field called TYPE.   The data contains 3 different types, "A", "B" and "C".
I would like to use Crystal Reports to count how many records are of type "A", how many of type "B" and how many of type "C".   The field is a string so simply TYPE = "C" will tell me if it is type "C".
Crystal Reports has a Set of Summary functions available in the Formula Editor.   One of the functions is Count() which counts the number of records.   The parameters are
       Count(fld),   Count(fld,condFld) or Count(fld,condFld,value).

Is there any way to do this.   I tried making a new formula field called TYPEAT such that
     if TYPE="A" then
         formula = true
    else
         formula=false
    end if

then I tried a second formula field typeac
     count(TYPE,TYPEAT)    
Thinking that TYPEAT IS NOW A CONDITIONAL FIELD.   The formula editor will not accept this.

I can use parameter fields and perform the calculations in the main program, but i would like to use a conditional count formula.    

Can this be done with Crystal Reports????
0
knk53
Asked:
knk53
  • 2
2 Solutions
 
mlmccCommented:
I assume you are selecting the fields when you build the summary.

Have you tried right clicking the field
Click INSERT --> SUMMARY
Can you insert a summary?

To summarize on a condition field it needs to be a group in the report.

Another way to do this would be


     if TYPE="A" then
         formula = 1
    else
         formula=0
    end if

You can then insert a summary as a sum to get the count.

mlmcc
0
 
knk53Author Commented:
mlmcc,
Thanks for responding
  I was already able to use a formula such as you suggested and return 1 or 0, then make another field that would SUM the first field.  However, that means I need to make 2 fields for each conditional count I want in my report.   The first field would return 1 or 0 based on the the condition.  The second field would sum the first field.  
 
Is there any way to create this as a single field, as opposed to 2 separate fields.
 
knk53
0
 
mlmccCommented:
Unless you are grouping by the formula you tried, no.

mlmcc
0
 
James0628Commented:
I'm not sure what you mean by "create this as a single field".  If you're trying to have one "field" produce a count for each TYPE, then, like mlmcc, I don't see any way to do it unless you're grouping on the TYPE, in which case you could show a count for each TYPE in the group footer.

 FWIW, in addition to mlmcc's suggesting of using formulas to produce a count of each TYPE, another option is to use running totals.  Running totals allow you to specify conditions, like only increment when TYPE is a certain value.  So, you'd have one running total for each value in TYPE.

 James
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now