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

Summing true/false statements?

Status
Not open for further replies.

smsherman

Technical User
Jun 8, 2005
21
US
Okay, a relatively easy proposition has led to several days of frustration.

I have two columns with similar date ranges. I need to do a summary comparison returning the total number of hits for each column. I also need to account for those instances where two dates occur for the same row(unique ID), counting the date for the column with the most recent date, and not counting the date for the column with the older date.

I have tried implementing an "if ({date1})>({date2}) then true else false" and then developing a count formula to tally the number of true... but it keeps counting false as well. I had set up the counting formula as follows: "if (@date1) = true then count(@date1),(@group)"

Any help would be appreciated. SQL database and Crystal 9. Thanks in advance!
 
What about a running total that duplicates the test?

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
I don't quite understand what you are suggesting. Could you clarify? Thank you.
 
Do a running total that evaluates based on a formula. Include the test in that formula.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Madawc means right click your boolean field, and select Insert / Running Total. Have it set to Count, evaluating on the formula "CurrentFieldValue = True", Reset on Change of Group.

Naith
 
Thank you, this seems to be improving the situation... however, I am confused by how I am to use the "CurrentFieldValue=True". I tried replacing the currentfieldvalue with my formula, but it still counts false hits.
 
Why not use a BINARY formula solution in the DETAIL section...?

if ({date1})>({date2}) then 1 else 0

You can then just sum that formula in your footer.
 
Tried that, didn't work. :(

I keep getting errors when I try the sum function (not to mention that Crystal reads the 1 and 0 and true/false statements and returns a value for the 0). All the variations of the sum have not worked and I usually end up with errors when I try to validate the equation.
 
Thank you MJRBIM! I rechecked some of my work and figured out where I went wrong with the sum check.

I just used that formula and did a sum in the group footer refrencing the formula (for some reason I previously wasn't able to choose sum from the drop down menu).

Anyway, thank you all for your help. The running total information was also helpful.

sms
 
I use Binary formulas all the time for this kind of issue - not sure why you are getting the errors.

Here's a data sample, formula, and result set...


Item_ID Open_Date Closed_Date More than 12 days
=======================================================
1 01/19/2005 04/24/2005 1
2 01/29/2005 02/12/2005 1
3 03/29/2005 04/12/2005 1
4 04/30/2005 05/11/2005 0
5 05/30/2005 06/13/2005 1
6 06/13/2005 06/22/2005 0
=======================================================
TICKETS OPENED MORE THAN 12 DAYS 4

FORMULA : More than 12 days
IF {Table.Closed_Date} - {Table.Open_Date} > 12 Then 1 ELSE 0

 
I'm not sure what I was doing wrong, but this is the final formula I put together:

if isnull(sum ({@IVCcount}, {@Staff})) then count ({R_MILESTONE_SUMARY.OBVERIFY_D}, {@Staff}) else
Count ({R_MILESTONE_SUMARY.OBVERIFY_D}, {@Staff})-Sum ({@IVCcount}, {@Staff})

The @IVCcount formula is: if ({R_MILESTONE_SUMARY.IBVERIFY_D}) > ({R_MILESTONE_SUMARY.OBVERIFY_D}) then 1 else 0

I also had a reverse (OVCcount formula) of the above to tally both seperate columns.

The isnull function was neccessary because otherwise if the sum came back without a hit, the final sum would not populate (even though there would be dates within the column/table).

I get the results I need! Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top