Tableau - Format dynamic fields populated using parameters

Contents

Contents

We are using the Sample - SuperStore dataset for this example. Lets take three measures: Sales, Profit and Quantity. We are creating a parameter to let the user select a measure name and the value on the viz changes dynamically based on the user selection. Next step is to create a calculated field to display the measure dynamically.

Now comes the issue. Calculated field can be formatted only one way: it can either be a currency or a number. How can you dynamically format and show the $ symbol when you select a currency measure.

I always thought this was not possible. But it has a fairly simple solution. Create another calculated field for just the formatting part. When parameter chosen is a currency measure, then show $ else ‘'.(please see the exact field on the attached viz)

Add both these fields to the text mark and place them next to each other.

Voila!

Link to viz: https://public.tableau.com/views/Formattingdynamicfieldsbasedonparameters/Dashboard1?:display_count=y&publish=yes&:origin=viz_share_link