5 Replies Latest reply on Feb 4, 2018 9:51 PM by Kemal Gürler

# Condition - Only one or all

Hello,

I have a dimension that contains two values. A and B.

I want to create a filter that "Local" shows only "A" values and "All" that shows sum of A and B.

IF [Dimension]="A" or [Dimension]="B" then "All"

elseif [Dimension]="A" then "Local" END

This is the formula I used but naturally once Tableau marked all "A"s as All, it does not work the way I want.

• ###### 1. Re: Condition - Only one or all

Hi Kemal,

Find my approach based on UNION as reference below and stored in attached workbook version 10.4 located in the original thread,

1. Define UNION

2. D1. All/Local: if [Table Name]="Sheet1" and ([dimension]="A" or [dimension]="B") then "All"

elseif [Table Name]="Sheet1\$" and [dimension]="A" then "Local" end

3. Drag the required objects to the indicated location and exclude Null from the object D1. All/Local

RegardsNorbert

• ###### 2. Re: Condition - Only one or all

Try making a String Parameter with the values "Local" and "All"

Then make a calculated field to show the dimensions:

IF [Dimension Parameter] = "Local" THEN

IIF([Dimension] = "A",[Dimension],NULL)

ELSEIF [Dimension Parameter] = "All"

[Dimension]

ELSE

NULL

END

• ###### 3. Re: Condition - Only one or all

Norbert Maijoor thank you but my dataset is already huge and union will make it even more complicated.

Josh Kushner, I tried your approach but it looks like I will need to include that parameter into every calculated field I used, which there are tens of them. Is there any other way to apply this parameter as a filter?

• ###### 4. Re: Condition - Only one or all

Hi Kemal,

Exchange your filter for a parameter

[Parameter]

Local

All

then a calculated field

if [dimension] = 'A' then [measure] end

Then in your parameter calculated field

case [Parameter]

when 'Local' then [the above calculated field]

when 'All' then 1=1

end

the 1=1 code is just a do nothing bit of code, but the result will be it displays both fields.

HTH

Peter

• ###### 5. Re: Condition - Only one or all

Hello Peter,

Thank you. The helper calculated field you put there has [measure] therefore this filter will apply to only that [measure]. However, I have tens of measures that will be effected by this filter I am trying to create so if possible I need more general solution.