If you've started using parameters to create selectable metrics in Tableau, exploring their uses through blogs by Charles Yi, Michael Bellamy, Vivian Ng, or others, you might have noticed some very annoying problems with bad units on your labels when using calculated fields to display those metrics. In a dashboard I made with Superstore, I had a parameter that let me select from Sales, Profit, or Profit Ratio for a dynamic bar chart:
To support that parameter, I had a calculated field to interpret the parameter and bring up the appropriate metrics (note that Profit Ratio is already an aggregate and doesn't need further aggregation:
And I got an output on Sales and Profits with no units that looked like this:
No problem, right? Right click the SM Metric field, change the number formatting to Currency (standard) or Currency (custom). Exceeeept...
If we do that, the profit ratio - which is a ratio best expressed as a percentage - will be in currency format. That would be raw anarchy, and our labels would look terrible. Or, we can leave the numbers unformatted, and our client will reasonably ask "Where are the units?" So, instead, just for the label and/or tooltip, we write two (or more) calculated fields to account for the two outcomes:
For time purposes, the first field says "If the parameter is not 'Profit Ratio', then pass through the calculated field for the metric; otherwise (i.e. if it is 'Profit Ratio' pass through nothing". You can right click this calculated field and turn it into Currency. The second field says "If it is 'Profit Ratio, pass through Profit Ratio specifically; otherwise, do nothing." This field I formatted as Percentage with one decimal place. Then, drag them onto the Marks card on the Label, Tooltip, or Detail tools:
In the label card, drop in the Metric Label Display and the Metric Profit Ratio Display next to each other. Even though both are active, only one will show at any given time, since you set up the logic in the calculated field making them mutually exclusive. And because of that, you can change the number format for both of the calculated fields to reflect Currency and Percentage, as needed, and give you two beautifully rendered labels depending on which view you've selected:
This takes time, and it's one of the more common things that comes up in client project reviews as a next step that couldn't be accomplished in the time allotted. There may be more efficient ways, but this method requires very little technical knowledge if you already know something of how to use parameters and calculated fields.