×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

# 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.

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!