4 Replies Latest reply on Jul 30, 2018 10:56 AM by Jim Dehner

# how to do a count if mulitple rows per ID contain "yes" all values will be "Yes"

Unfortunately I can't attach a packaged workbook since I'm dealing with confidential info but here's a snippet to help explain.

So what is not shown is a field to the left of these columns which is a unique ID.  My goal is to be able to write a calculation to say if there is a Yes for a unique ID (since some of the unique IDs have both a Yes and No) can we translate that entire row to just "yes".  I basically just need one answer per unique ID and if one of the rows per Unique ID has a yes, all should be yes.  If No, all are no.  Hoping this wasn't too confusing....thanks!

• ###### 1. Re: how to do a count if mulitple rows per ID contain "yes" all values will be "Yes"

Hi Kelly

without seeing more this  is a best guess but create an LOD     find max      {fixed [ID] :max([yes No filed])}

where the yeas No field is the name of your 3rd column

then you can either use a filter setting find max = "Yes"

or you can use it in a calculation

if  [find max]='Yes' then 'Yes' else 'No" end

Tableau will use alphabetical order to find the max of string vaules

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.

1 of 1 people found this helpful
• ###### 2. Re: how to do a count if mulitple rows per ID contain "yes" all values will be "Yes"

See if this helps:

Since you have not provided a header for the columns, I am assuming the column name to be "Flag" with the values being Yes or No.

Create a calculated field with the following content and see if you have the desired result:-

IF {FIXED [Unique ID]: SUM(IF [Flag]="Yes" THEN 1 ELSE 0 END)} > 0 THEN "Yes" ELSE "No" END

1 of 1 people found this helpful
• ###### 3. Re: how to do a count if mulitple rows per ID contain "yes" all values will be "Yes"

Thank you so much Jim!  This worked perfectly.

• ###### 4. Re: how to do a count if mulitple rows per ID contain "yes" all values will be "Yes"

Glad to help Kelly

Have a good day

Jim