INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to get an accruate sum of the Yes values?

How to get an accruate sum of the Yes values?

(OP)
I need to figure out a way to get a sum of just the yes values. It puts a yes if the employee should get Per Diem that day and a no if they do not. I have done this over and over in Crystal reports and in Crystal I would just create a formula to put a 1 for yes and a 0 for no. Sum it and be done. However, I have tried this in Report Builder and it doesn't work. When there are 4 days (3 yes and 1 no) no matter what I do I get 4.

Any ideas?

RE: How to get an accruate sum of the Yes values?

Hi, I think you can do this by either SUM() or COUNT().

Assuming that your fieldname that records the Yes or No is called perDiem, then something like this should work:

CODE

//Using COUNT
COUNT(IIF(Fields!perDiems.Value="Yes",1,Nothing)) 

CODE

//Using SUM
SUM(IIF(Fields!perDiems.Value="Yes",1,0)) 






RE: How to get an accruate sum of the Yes values?

You can use the Case Stmt with SUM like this:

SUM
(
CASE
WHEN fieldname = 'Yes' THEN 1
WHEN fieldname = 'No' THEN 0
ELSE 0
END
) AS YesCount

If you COUNT, you'll get the count of all records.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close