Skip to main content

Hello all,

I am looking for something like this calculation.

 

if parameter = 1

then

columnName IN ("parameterValue1")

elseif parameter = 2

columnName IN ("parameterValue1","parameterValue2")

else "All values of ColumnName".

 

basically user can filter on 1 value OR 2 values or keep All values.

I need parameter because we need to filter through URL.

 

Is this possible?

 

I know IN operator is not allowed in calculations but is there a workaround to achieve this result?

 

any help will be appreciated.

Thanks

2 answers
  1. Oct 21, 2016, 4:08 PM

    Hi there! Unfortunately, as you've noted, there's no IN keyword in Tableau. However, you have a few options.

     

    First of all, you could just use the OR keyword, e.g.

    columnName = "parameterValue1" OR columnName = "parameterValue2"

    Alternatively, you could do a neat trick with CONTAINS(). Specifically, you would search for your columnName value within a concatenation of your two parameter values. Something like this:

    CONTAINS("parameterValue1||parameterValue2||", [columnName] + "||")

    The reason for the double pipes (or it could be any unusual combination of characters) is to make sure that you don't get an internal match (e.g. matching "meterVal").

0/9000