KNOWLEDGE BASE

Unable to Display Different Number Format for the Same Field Conditionally When Switch Measures Using Calculation Fields


Published: 24 Nov 2021
Last Modified Date: 25 Nov 2021

Issue

Unable to conditionally display different number format for the same field based on the selections of parameters.

For example,

When selecting [Ratio (number-decimal-format)] option on parameter on worksheet [Sheet1] contained in workbook [DynamicNumberFormat.twbx] attached, the value displayed on Furniture column is 20, however decimal format like 20.0 is expected for this metrics selection.



 

Environment

  • Tableau Desktop

Resolution

Workaround 
Convert the numeric data into text type and use calculation field to format it.
An example is demonstrated in the [Solution] worksheet in attached workbook.

1. Create a calculation field [Dynamic Metrics(String)]
CASE [Select a field to display]
WHEN "1" THEN STR(ROUND(SUM([Profit]),0))
WHEN "2" THEN STR(ROUND(SUM([Ratio]),1))
END

2. Display  [Dynamic Metrics(String)] on text marks.

Cause

The ability to conditionally change the number format set on the same data field is not built into the product currently.
Did this article resolve the issue?