Crystal report counting string values

42 Views Asked by At

I have a subreport that I am trying to look at a string value (not a numerical value) and if it is not null then to add 1 to a total and I need to keep a running total of this value per grouping in my main report. I need to be able to use this value in my main report so that I can figure out the percentage of times the form was filled out. I have a formula that I've been "using" in my subreport

//@IncrementCounter formula in Subreport

WhilePrintingRecords;

Shared NumberVar Countersub := 0;

If Not IsNull ({Data_Entry_By_Login}) Then Countersub + 1 ;

But this only either gives me a 1 or a zero and I can't figure out how I would either change this to count all the values in my grouping from my main report or in my main report how to see this formula and total this so I can then get my percentage. Any help would be greatly appreciated, as I feel I have tried everything. I am not new to crystal reports but I have never had to try and summarize/count a string field in a subreport per grouping so that I can then retrieve and compare this value in my main report.

I have read through previous questions and tried the solutions listed but I constantly run into the issue in my formula field that my field is not a numerical value or that it can sum the field.

2

There are 2 best solutions below

2
MilletSoftware On

Your formula always resets the shared variable to zero. It also doesn't assign the incremented value back to the variable.

Try something like:

WhilePrintingRecords;
Shared NumberVar Countersub;
If Not IsNull ({Data_Entry_By_Login}) Then Countersub := Countersub + 1 ;
0
MilletSoftware On

To reset on change of group, place the following formula in the Group Header:

Shared NumberVar Countersub := 0;