6 Replies Latest reply on Oct 16, 2018 2:55 AM by amar savale

# Parameter + Calculated field, filters a dimension

Hi guys.

I was wondering if someone could help me with a formula i'm struggling with.

So, I have a dimension called "Product" which contains my products as well as my competitors product.

Also the dimension "Product" contains 10 products from 1 to 5 my products and from 6 to 10 competitors products

My goal is to create a button which will allow me to choose either "my products" or "my competitors products".

what i've tried:

create a paramater with two options "my product" ; "my competitors product"

create a calculated field: IF [Parameter].[Product_Button]="My product"

THEN [Product]= "1"  AND [Product]= "2"  ....

ELSE  [Product]= "6" AND [Product ]= "7"  ....

END

in other words i don't know how to tell tableau that if it's "my product" it has to take the products from 1 to 5 but if it "my competitors product" it should take products from 6- 10

PS: Product is a string, i put numbers just to make it anonymous and easier to write.

Thank you guys in advance !

• ###### 1. Re: Parameter + Calculated field, filters a dimension

May be this?

thanks

Deepak

• ###### 2. Re: Parameter + Calculated field, filters a dimension

Hi see the attached

you didn't include your twbx workbook so I had to use superstore data

somewhere in your data you also identify the manufacture? (you or the competitor?)

then you can create a simple filter - i used category as a proxy

create the parameter and edit it to make it a button

then create a formula as a filter

place the filter on the filter shelf and set to True - it will now filter any data in the viz by the Mine / Theirs parameter value

eg - if you just make a text chart / a graph, use ranking - any and can be combined with any other filer

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.

• ###### 3. Re: Parameter + Calculated field, filters a dimension

Hi Maxime,

You can try below approach:

I am assuming your data is like:

create a parameter:

Logic  =

if CONTAINS("A,B,C,D,E",[Product])=TRUE then "my products"

ELSEIF  CONTAINS("F,G,H,I,J",[Product])=TRUE then "my competitors products"

END

Flag =

[Logic]=[Select product type]

Drag "Flag" to filter and select TRUE.

• ###### 4. Re: Parameter + Calculated field, filters a dimension

Hi, thanks for you answer, i have tried your method but when i try to create the flag calculated field I get an error saying I can't compare booleans with strings. Any idea?

• ###### 5. Re: Parameter + Calculated field, filters a dimension

Hi Maxime,

Have you exactly used the same logic that i have suggested ??

Logic  =

if CONTAINS("A,B,C,D,E",[Product])=TRUE then "my products"

ELSEIF  CONTAINS("F,G,H,I,J",[Product])=TRUE then "my competitors products"

END

Flag =

[Logic]=[Select product type]

In "IF" condition you have to use only TRUE not "TRUE"   as  TRUE within quotes is considered as string and without string its booleans.

• ###### 6. Re: Parameter + Calculated field, filters a dimension

Hi,

Please find the attachment if it is Correct or Helpful for you.

Thanks,

Amar D. Savale