9 Replies Latest reply on Nov 19, 2018 8:53 PM by MUHAMMAD MAHMOD

# Calculation in Tableau (CONTAINS Formula)

Hi Tableau community

Below is my sample data.

 Paper Numbers Roles Paper 1 Speaker Paper 1 Chair Paper 2 Speaker Paper 3 Chair Paper 4 Speaker Paper 5 Speaker Paper 6 Speaker Paper 6 Chair

i want to identify which papers that have Speaker AND Chair using CONTAINS Formula.

Appreciate if u can help me

• ###### 1. Re: Calculation in Tableau (CONTAINS Formula)
2 of 2 people found this helpful
• ###### 2. Re: Calculation in Tableau (CONTAINS Formula)

Hi Mahmod,

Please try below code and do let me know if it is working.

IF CONTAINS([Roles]," Speaker ") AND

CONTAINS([Roles], " Chair ") then "TRUE"

END

Thanks

Milan

• ###### 3. Re: Calculation in Tableau (CONTAINS Formula)

Dear Akram,

sorry i'm not found your attachment.

Thanks

• ###### 4. Re: Calculation in Tableau (CONTAINS Formula)

Hi Milan,

Sorry, it is not working.

Thanks

• ###### 5. Re: Calculation in Tableau (CONTAINS Formula)

Hi Muhammed,

What version of tableau you are using? Is there any any error in opening the workbook pls let me know!

Attaching the workbook again!

• ###### 6. Re: Calculation in Tableau (CONTAINS Formula)

Hello Muhammad,

Use the below formula to get the desired results.

IF CONTAINS([Roles]," Speaker ") OR

CONTAINS([Roles], " Chair ") then "TRUE"

END

Thanks

Sandeep

• ###### 7. Re: Calculation in Tableau (CONTAINS Formula)

Akram's method and attachment are good.

Milan and Sandeep's formulas don't work because there are multiple Roles records for each Paper that need to be scanned separately.

Here's the general LOD calc to do what you want, put this on the filter shelf set to True.

{ FIXED [Paper Number]: SUM(IIF(CONTAINS([Roles],"Speaker"),1,0,0)) > 0

AND SUM(IIF(CONTAINS([Roles],"Chair"),1,0,0)) > 0 }

1 of 1 people found this helpful
• ###### 8. Re: Calculation in Tableau (CONTAINS Formula)

+ open the thread itself to see the attachments, to mark the responses as helpful and/or correct not in inbox view.

• ###### 9. Re: Calculation in Tableau (CONTAINS Formula)

Thank you ZACH LEBER,

that is the answer i'm looking for. very helpful.