Skip navigation

Apply number formatting inside a calculated field

score 855
You have not voted. Active

I need to be able to take numbers and apply number formatting to them based on the logic of my calculation.  The number formatting should be exactly the same as the "Custom" formatting that tableau does now.  So, if I have a calculated parameter that should be a percentage sometimes and an integer other times, I could say


if <condition> then Format([percentage], "#.00%") else Format([integer],"#,##0.0") end


Key Benefits:

1) Allows you to format measures depending on the parameter. 

Example: You want to allow the user to select whether to display a measure in thousands, millions, or units. 


Case [Size Parameter] when "Thousands" then Format([number],"#,.0") when "Millions" then Format([number],"#,,.0") else format([number],"#,###.0" end


2) Gives you more granular control over how to format numbers

3) Allows logic to apply to formatting


Vote history