Conditional graph () in crystal report

How to get the result using a formula field in crystalreport to count the number of records where fieldname = xxx

like: select count (*) as cnt from tbl where f1 = xxx

and explain more with examples of the count () function of the crystal report.

Project: VB.Net Best regards, Sensa.


source to share

3 answers

you are basically creating a formula field like:

if {mytable.field} = 'xxx' then


then count({formula})


or use running totals with a scoring formula: {mytable.field} = 'xxx'



There are several alternatives with certain disadvantages.

1) Use the select expert to conditionally restrict the records in the report. The main disadvantage in this case is, of course, the loss of data, probably related to other parts of the report.

2) Solution 1) using a subsection integrated into the main report. The problem in this case is formatting limitations

3) Use grouping. I.E. group by mytable.field uses the total number of records in the records with the group and insert into the group header. Hide the group selectively via the section specialist. Here again comes the problem of additional formatting constraints.

4) Finally, if you have access to the actual database. Create a view, it will be the best solution in terms of performance and formatting issues in Crystal reports. However, creating a view every time this problem occurs can pollute your database with views that will not be used often.



You can try this:


if {anytable.yourfield} = 'xxx' then 1 Else 0;


And then:




For integers:


CSTR (sum({formula1}),0);




All Articles