3 Replies Latest reply on Jun 19, 2018 7:19 AM by Charles Wang

# Count row based on values in 2+ columns (countif?)

Hi all,

Please see my mock data below. I am trying to count every row/ID in a dataset for which there is a value of 1 in Indicator 1 and Indicator 2. If there is a 0 in either indicator column, I do not want to count that row.

 ID Indicator 1 Indicator 2 555 1 1 552 1 1 106 1 0 136 0 1 632 0 1 754 1 1

I understand how to do it in Excel but the data has so many rows that I must use Tableau. I am not sure if there is an equivalent function to use here.

Much thanks in advance!

• ###### 1. Re: Count row based on values in 2+ columns (countif?)

Good morning Charles

There are several ways to do this

this (without LOD)

If Min([Indicator 1],[Indicator 2]) >0 the countd(ID) End

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 2. Re: Count row based on values in 2+ columns (countif?)

Hi Charles,

Please use this calculation:

COUNTD( if Min([Indicator 1],[Indicator 2]) >0 then (ID) END)

Thanks and please find attached workbook.

Mavis

2 of 2 people found this helpful
• ###### 3. Re: Count row based on values in 2+ columns (countif?)

Hi Jim,

Thanks for the reply! I'm assuming I am supposed to create a calculated field with this formula and drag it on to my ID measure? However when I create this calculated field , it gives the error "Expected 'THEN' to match 'if' at character 0" at the expression 'the.' If I change it 'the' to 'then,' it red underlines the whole expression with the error "cannot mix aggregate and non-aggregate comparisons or results in "if" expression."

Thanks very much.