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!

conditional count

Status
Not open for further replies.

see123

Programmer
May 11, 2001
28
0
0
US
Hi,

My report looks like this

Group : abc # users = 3 Count of active users ?

Name date Status
---------------------------------------------
aaa 01/01/01 Active
bbb 01/01/01 Active
ccc 01/01/01 Inactive

Group : XYZ # users =3 Count of active users ?

Name date Status
---------------------------------------------
aaa 01/01/01 Active
bbb 01/01/01 Active
ccc 01/01/01 Inactive

I wanted to count only active users on each group. can anyone help me out?
 
You will have to create a formula like this one

if {Table.status} = "Active"
then 1
else 0

Now can do a count/summary of this formula.

Kchaudhry
 
Hi KC,
its displaying inactive count also.

here is my @count:


IF {rpt_SK_user_activities;1.Active} = true then
1
else
0



Count(@count)
 
Does the nam constitute a user?

If so, just right click the name field in the details and select Insert->Summary->Distinct Count

Now drag this up to the group header if that's where you want to display it.

-k
 
Use KChaudry's formula but insert a sum, NOT a count, since a count will count any result (0 or 1) for a formula. You do not need to write a formula for the summary--just right click on the first formula and choose insert summary->sum.

-LB
 
I think your best bet is to use a conditional running total. Select the name field and Insert - Running Total. For evaluate, select Use a formula and click the conditional button (x-2). In the formula editor, put {rpt_SK_user_activities} = 'Active'. For Reset, select On Change of Group, and select the appropriate group.
 
You could use either a conditional formula or a running total, but whenever possible, it is better to use a conditional formula, because running totals can slow your report, especially if you are using many of them.

-LB
 
lbass,
I have always believed that a report would run faster if you used Crystal functions, such as the running total as opposed to creating manual running totals through formulas. Why would a Crystal running total be slower?
 
GMcNamara,

A conditional formula is not the same as a manual running total. The following is a conditional formula which allows you to insert summaries:

if {Table.status} = "Active"
then 1
else 0

A manual running total would take the form of the three-formula method, with a reset formula, detail level formula which increments a value, and a display formula. I would think that a manual running total and a running total created by the running total editor would have the same impact on speed.

It may be that for most CR users the difference in speed is negligible--I am astonished when users complain of a report taking two minutes. Because of my connectivity to a very large, complex database, a few of my reports take hours, while simpler ones take a few minutes to 20 minutes. For me, the use of multiple running totals, e.g., maybe 50 in one report, means a very long wait. I think the issue is that running totals are calculated on the client side. On the other hand, sometimes running totals are the only solution that works for the particular reporting need.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top