7 Replies Latest reply on Sep 10, 2018 4:23 AM by Manika Chhabra

# Count the rows from a boolean field for each value

How do you create a field which SUMs or COUNTs the number of rows with a specific boolean value?

• ###### 1. Re: Count the rows from a boolean field for each value

I don't have Tableau in front of me, but can you write a calculation similar to:

SUM(IF [Field]=TRUE then 1 else 0 end)

or in some cases, it makes sense to return a field like an ID

COUNT(IF [Field]=TRUE then [ID] end)

I use these types of calcs often in my work, but I'm not clear if this is what you are looking for.

1 of 1 people found this helpful
• ###### 2. Re: Count the rows from a boolean field for each value

Thank you.  I think the SUM() worked.

Regards,

• ###### 3. Re: Count the rows from a boolean field for each value

Great!  If you have a resolution, make sure to mark the question as "answered" so other folks know you've found a solution.  Cheers!

• ###### 4. Re: Count the rows from a boolean field for each value

Just marked it as “Assumed Answered”.  (Hope that’s right.)

Thank you again.

• ###### 5. Re: Count the rows from a boolean field for each value

We typically mark the responses from helpers as "Correct" or "Helpful" within the replies we receive on the Forum, but I don't mind a bit--this just helps us keep the forums a bit 'cleaner', as they tend to get pretty messy at times.

• ###### 6. Re: Count the rows from a boolean field for each value

SUM(IF [Field]=TRUE then 1 else 0 end)

COUNT(IF [Field]=TRUE then [ID] end)

but it didn't work for me.

I posted details of my workbook on the link: http://https://community.tableau.com/message/601346#601346

Do you think would you have another recommendation?