When you use a parameter in Tableau to swap between KPIs, you inevitably run into the formatting problem:
- Revenue should look like $12,540,
- User count should look like 1,294,
- Conversion rate should look like 23.4%,
And Tableau insists on applying one number format to all values coming out of a parameter-driven calculation. If one KPI is a percent and another is a currency? Too bad. Tableau formats the entire field based on the last pill’s number formatting.
This post walks through the simplest, most reliable way to dynamically format each KPI correctly—using a single CASE statement with explicit formatting logic per KPI.
The Core Concept
You’ll build:
- A numeric version of your KPI (used for axis, color, filters).
- A formatted string version of the KPI (used for labels, tooltips, text).
The numeric version stays unformatted.
The string version handles formatting per KPI.
This separation is what makes the whole thing work smoothly.
Step 1 — Create the Raw KPI (Numeric Only)
This calculation returns the underlying values, not formatting.
CASE [KPI Parameter]
WHEN 'Revenue' THEN SUM([Profit])
WHEN 'User Count' THEN COUNTD([Customer Name])
WHEN 'Conversion Rate' THEN [Profit Ratio]
ENDUse [KPI Value] for charts, axes, sizes, colors, filters.
Do not format this field—leave it numeric.
Step 2 — Create the Formatted KPI (String)
This is the value you display to the user. Each KPI gets its own formatting rules inside the CASE block. Below are the most commonly needed formats:
- currency
- whole numbers
- percentages
CASE [KPI Parameter]
//Currency
WHEN 'Revenue' THEN '$' + STR(ROUND(SUM([Profit])))
//Number
WHEN 'Users' THEN STR(COUNTD([Customer Name]))
//Percentage
WHEN 'Conversion Rate' THEN STR([Profit Ratio] * 100) + '%'
ENDUse [KPI Label] only for:
- marks labels
- tooltips
- text tables
- headers
This ensures Tableau displays the correct format without messing with numeric behavior.
Why This Approach Works
Tableau cannot dynamically switch number formats for a single measure. But it can switch strings with no problem. By splitting the KPI into:
- numeric → for calculations
- string → for display
…you preserve everything Tableau needs for analytics, and you control everything the user sees.
