7 Replies Latest reply on Jul 18, 2018 8:45 AM by Jim Dehner

# Calculation based on boolean status

Hi,

New user here. I want to make a chart based on sample status and whether it has been returned or not.

The issue i have is that I have multiple entries per sample, some have Returned=True, some=False - for the same sample. The rule is that if any entries for that sample have Returned=True, then the Returned value for the sample is True.

When i make a chart on the below data, it indicates there are 5 samples in total where i have only 4 in reality. I need a calculation that sees whether there are any "true" values in the Returned column based on the sample id and outputs appropriately and use this column instead. could you please help with the calculation?

Thanks  • ###### 1. Re: Calculation based on boolean status

Good morning

one way to do tht is with an LOD like   {fixed [sample]:max([Return])} = True

you can use it as a filter or or in a condtional statement like     if  {fixed [sample]:max([Return])} = True  then (Sample) end

you may need to play with the syntax - you didn't include a TWBX workbook with your data so I was not able to test the expression

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: Calculation based on boolean status

Hi, Kevin

create a calculation as return shown below and drag it to color Hope this helps

ZZ

1 of 1 people found this helpful
• ###### 3. Re: Calculation based on boolean status

Thanks Jim, I used the LOD option and it works. In terms of understanding the syntax {fixed [sample]:max([Return])} = True, could you please explain the expression part? Is it stating that if anything in [Return] = True, only return this as a count of 1? It works but im trying to work out how!

• ###### 4. Re: Calculation based on boolean status

Thanks ZZ

• ###### 5. Re: Calculation based on boolean status

Kevin

the conditional (if... then ... statement ) takes advantage of the fact that Tableau will use the Alphabetical order to determine max or min of non - numeric values - T >> F

an LOD expression can verbalized as for each sample take the max value Return = if it is True then take the sample value

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.

• ###### 6. Re: Calculation based on boolean status

Great, thanks again Jim

• ###### 7. Re: Calculation based on boolean status

If you are satisfied with the initial response correct to close the thread

Thanks

Jim