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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I conditionally count records? 1

Status
Not open for further replies.

xsw1971

Programmer
Jun 21, 2001
153
US
My report has one group, each with a varying amount of detail. I need to go the first record in each group, and if it matches a certain criteria, then count it. Otherwise move to the next group (not the next record in the current group.) My counter will never reset.

EXAMPLE:
Group 1
Closed 7/6/01
Testing 6/1/01
New 5/31/01
Group 2
Testing 6/15/01
New 6/10/01
Group 3
Rejected 5/1/01
New 4/28/01

CONDITION:
not ({GL_REQUESTS.STATUS} in ["CLOSED","CANCELLED","REJECTED"]) then...
this is where I want it to count or pass. In this example the count would be 1.

I have been playing around with variables and running totals and formulas and just can't seem to find the right combination. Any ideas?

Thanks
 
What version of CR? If you have v7 or v8 the simple way would be t create a formula that says:

if not ({GL_REQUESTS.STATUS} in["CLOSED","CANCELLED","REJECTED"]) then
1 else 0

Place this on the detail band.
Now insert a running total using sum (not count)of this formula field using the automatic running total feature. Set the evaluate to "On Change of Group" which only counts the first record in each group. This "sum" will give you your count. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Thank you, this works great. However it brought up another issue which I just cannot solve. The "if..1..else..0" solution works well if I only have one condition to meet or not meet. However, the first record of each group is one of 7 different statuses. I am trying to create a summary which looks like:

Total Closed: [number]
Total Testing: [number]
Total Rejected: [number]
etc.

I've looked at doing conditional running totals, but then I can't "evaluate once per group", which only looks at the first record. Again, I only want to evaluate the first record in each group.

Any ideas? Thank you!
 
Create one formula per status:

If status = "Closed"
then 1
else 0

Then create a running total for each formula, that evaluates once per group. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top