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 Chris Miller 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.

Guest_imported

New member
Jan 1, 1970
0
I have a group that diaplays calls by date, i need to count all the calls that are still open within each group. I can do this buy creating 2 formulas - one that displays '1' every time the ISOPEN field is 'T' then a second field to count up all the '1's but there must be a more efficient way?? had a play with the 'Count (Fld, CondFld, Cond)' tried the following syntax
Count ({CALLS.CALLNO}, {CALLS.ISOPEN}, "T") expecting this to count all the CALLNO where ISOPEN = "T" but unfortunately this gives me an error 'The summary \ running total field cannot be created.' any ideas or do I have the wrong end of the wrong stick? Cheers.
 
You can simply create a Running Total with that condition.

If you want to keep the 0/1 approach then be sure to SUM rather than COUNT that formula.

Cheers,
- Ido CUT & Visual CUT: e-mailing, exporting, bursting, distribution, and scheduling of Crystal Reports:
 
When those examples say condField they don't mean logical condition, they mean group condition (which would be clearer if they just said GROUP). That is for creating subtotals, not conditional totals.

A true conditional total uses a formula that is:

if {CALLS.ISOPEN} = "T"
then 1
else 0

You can then sum this (subtotal or grand total) to get your open calls. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hello, this is my case,
there is 10 lines at invoice paper... I want to print the grand total at the line 11, without concerning how many order line I have.

If I have 20 order line, then the grand total will be printed at the second paper (the first paper will shown nothing)

Darwin
Programmer
 
You can use the "print at bottom of page" option in the report footer. Then it will always print at the bottom of the last page.

Lisa
 
In Mr. Hamady's post,
He says:

if {CALLS.ISOPEN} = "T"
then 1
else 0

I have a similar situation but i have 3 different output in that group, I'm using CR8.5 and in this version, it only takes the last value of that group...

so when I make

if {CALLS.ISOPEN} = "T"
then 1
else 0 it's ok

but if I put some other value instead of T which is already exist in that group, it returns 0 but it should produce some other result which is equal to that value...

What's the problem here?

Thanx
 
Not sure I follow - please post the exact formula that doesn't work.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Sum ({ado.DURATION},{ado.TYPEOFTARIFF} , "N")
 
You have been fooled by CR's dumb argument names. The
'condition' argument in the SUM function is for GROUP conditions, not logical conditions. So you can't do a conditional total using the formula you have written.

Try:

If {ado.TYPEOFTARIFF} = "N"
then {ado.DURATION}
else 0

Then do a subtotal or grand total of this formula.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
ok i tried this one as well, but please read the last paragraph of my first post...

I have 3 types of TYPEOFTARIFF N,L,I

so in group TYPEOFTARIFF

L = 3000
I = 2000
N = 1000

If {ado.TYPEOFTARIFF} = "N" then
Sum ({ado.DURATION}, {ado.TYPEOFTARIFF})

In this case it produces 1000 (that's what I want, it does)

problem:if I change formula like that;

If {ado.TYPEOFTARIFF} = "I" then
Sum ({ado.DURATION}, {ado.TYPEOFTARIFF})

In this case it produces 0 (that's NOT what I want, i'm expecting 2000)

Thanx
 
That is because you keep using the SUM function in your formulas, and my technique does not use the SUM function in a formula. You can do your totals without formulas and then you wont' have to deal with learning the way that the SUM function works in CR formulas.

Write three formulas just like this one, using your three values for the condition:

If {ado.TYPEOFTARIFF} = "N"
then {ado.DURATION} // or < then 1 > if you want to count
else 0

Place these formulas on the details band and then use &quot;Insert - Grand Total&quot; to get a total of each formula. These three grand totals will be your category totals. You don't even need to group on the TypeOfTariff for this to work.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top