cancel
Showing results for 
Search instead for 
Did you mean: 

Group Counter Condition

Former Member
0 Kudos

Hi,

i want to count items in a group. Normally this can be done using a group counter. What I need is to decide if an item matches a certain condition only then the count should be increased.

Kind regards

Patrick

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Patrick,

This can be done using RunningTotals :

Create a running total from Field explorer.

--Select the field to count and select type of summary Count

--In Evaluate select Use a formula

Then give the condition like .. If = <value> then True

--Under Reset select on Change of Group.

Place this formula on group footer to display the count for each group.

Thanks,

Sastry

Former Member
0 Kudos

Sastry,

this works great. Thank you for assistance.

One Question remains. Using the GUI I can not add a sum of running totals. Is this by design. If yes I will create another running total which does this addition.

Sincerely

Patrick

Edited by: Patrick Jox on Sep 18, 2008 3:44 PM

Former Member
0 Kudos

Yes.. this is becaue in running total you are using a count aggregate function. In crystal it will not allow you to use two aggregate functions in one formula or in one total.

You may have to use running total to get sum of your count.

Regards,

Sastry

Former Member
0 Kudos

Patrick:

Take a look at my previous post. I think you will find the method that I suggested very straight forward and very easy to expand it to the different levels you need it.

Thanks

Brian

Former Member
0 Kudos

Brian,

my problem is that I want to decide if a goup has changed in the formula. So I use the following code to decide if group has changed or not:

if Previous({Befehl.TicketID}) = {Befehl.TicketID} then

1

else

0;

After having inserted the formula in the details section the insert menu only offers "field title" but not "Summary"

Kind Regards

Patrick

Edited by: Patrick Jox on Sep 19, 2008 8:54 AM

Answers (2)

Answers (2)

Former Member
0 Kudos

A third way to do it is to create a simple formula that you can insert a summary on. I prefer this method when I can use it because it is the most efficient because Crystal will perform it before the records are printed. The other two methods that were suggested will work too, but they are performed while records are being printed.

Create this formula:

//@Counter

if {table.field} = "Match"

then 1

else 0

Then you can insert a summary on it using the Insert menu, Summary command. Pick the formula, choose the summary type (should be Sum), and then pick the Group you want to total it at.

If you need a summary at another level (group or report level), you can simply copy the created summary field, and paste it in any other group header/footer or report header/footer.

Edited by: Brian Reed on Sep 18, 2008 3:48 PM

Former Member
0 Kudos

Hi Patrick,

You can try below Formula:

// For instance, if Condition is Last Yearu2019s Sales > $5000 then increase the Counter.

//Create a formula named As @CalculateCount to display the number of Records which matches above condition. Place this formula in the Detail Section.

WhilePrintingRecords;

Global numberVar counter;

If {Tablename.Last Yearu2019s Sales} > $ 5000 then

Counter := counter + 1;

Regards,

Alpana