Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summary - Only When ........

Status
Not open for further replies.

TopJack

Programmer
Mar 10, 2001
153
0
0
GB
Is it possible to summarise a field only under certain criteria.

I'm trying to use the DistinctCount function to distinctly count (number) records only if they are not equal to zero.

I want to use this ......

DistinctCount ({@NumberValue},{Week})

...... only if {@NumberValue} does not equal "0".

Any help would be much appreciated.
 
As long as your version allows it, you can set up a Running Total set to DistinctCount, and evaluate on {@NumberValue} <> 0.

Of course, this is only if NumberValue is the kind of formula which allows for summary activity.

Naith
 
Thanks for the advice Naith - its version 8 by the way. I will give that a try.

I will post back my outcome on Monday.
 
Thanks again Naith. Do you work for Crystal ? - don't answer that.

I tried the running total using DistinctCount. The summary worked but the criteria was not selecting properly. Maybe I was doing something wrong.

You triggered a thought and I have managed to get the results using an If statement on the group summary (week).

if (Minimum ({@NumberValue},{Week})=0) then
DistinctCount ({@NumberValue},{Week}) - 1
else
DistinctCount ({@NumberValue},{Week})


I have used the idea that if a record exists containing 0 then just take 1 of the total, therefore not including those records in the count.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top