9 Replies Latest reply on May 31, 2016 7:58 AM by Bassem Khalil

# Creating one calculated field that applies to all variables

Hi experts,

I have ratings for few variables and I need to calculate the Topbox% for these ratings.

Topbox = round(sum(if[Recommendation]>=9 then [weight] else null end)/sum([weight]),6)

Instead of creating the Topbox multiple times for multiple variables, is there an option to create one variable for Topbox as per the above calculation and then apply this to all variables.

Attaching the workbook in which I have calculated Topbox for Recommendation.

I need similar Topbox calculated fields for other variables but not by creating multiple variables instead by creating one variable.

• ###### 1. Re: Creating one calculated field that applies to all variables

Would the below be of any help? the view/calculation changes based on the parameter selection which replaces in your formula the measures and calculates accordingly.

• ###### 2. Re: Creating one calculated field that applies to all variables

Hi Khalil,

Could you please share the workbook that has parameter calculation.

• ###### 3. Re: Creating one calculated field that applies to all variables

For sure! Please find attached the workbook (version 9.3)

Best Regards,

B

• ###### 4. Re: Creating one calculated field that applies to all variables

I am unable to open the workbook since I am using version 9.

Could you please share the calculation?

• ###### 5. Re: Creating one calculated field that applies to all variables

Of course...

This is the parameter that I created

And this is the calculation

IF  [MeasureType]="one"

THEN round(sum(if[Recommendation]>=9 then [Weight] else null end)/sum([Weight]),6)

ELSEIF   [MeasureType]="two"

THEN round(sum(if [Repurchase]>=4 then [Weight] else null end)/sum([Weight]),6)

ELSEIF [MeasureType]="three"

THEN round(sum(if [Satisfaction]>=3 then [Weight] else null end)/sum([Weight]),6)

END

• ###### 6. Re: Creating one calculated field that applies to all variables

Thank you so much Khalil.

Just checking if we can have all of those variables in the row instead of filters.

• ###### 7. Re: Creating one calculated field that applies to all variables

Currently, Tableau does not support multiple selection parameters that can help in some way to display all three options in the view.

The above is the only approach I know of that let's you have a dynamic field/variable.

Hope this helps!

• ###### 8. Re: Creating one calculated field that applies to all variables

Thanks a ton Khalil

1 of 1 people found this helpful
• ###### 9. Re: Creating one calculated field that applies to all variables

You're welcome!