Custom number formats are a useful way to keep your axes tidy and to have better control over how your numbers appear in Tableau. This blog will go over why they are useful and what they can be used for, the structure of the custom number format string, the format characters and some useful examples. This is the first in a series looking at custom number and date formatting across Tableau and Power BI.
Why Use Custom Number Formats?
Before diving into custom number formats, it's worth noting that Tableau already includes a wide range of built-in formatting options.
Using the Format pane, you can quickly display values as:
- Currency
- Percentages
- Scientific notation
- Thousands, millions or billions
- Values with a fixed number of decimal places
For many dashboards, these built-in options are all you need, however, sometimes you need something slightly more customised:
| Requirement | Example |
|---|---|
| Display a dash instead of zero | – |
| Show brackets around negative values | (£1,250) |
| Add units to a value | 125 Customers |
| Add directional indicators | ▲ 15% |
| Combine scaling with custom text | £1.2M Revenue |
This is where custom number formatting becomes useful.
Rather than creating calculated fields purely to change how values are displayed, custom number formats allow you to control the appearance of a number directly within Tableau.
Understanding the Structure
A custom number format can contain up to three sections:
Positive Format ; Negative Format ; Zero Format
For example:
£#,##0 ; (£#,##0) ; –
would display:
| Value | Result |
|---|---|
| 1250 | £1,250 |
| -1250 | (£1,250) |
| 0 | – |
Think of the semicolons as separating instructions for different scenarios.
The first section tells Tableau how to display positive numbers, the second controls negative numbers and the third controls zeros.
Scaling Numbers: Thousands, Millions and Billions
One of the most useful tricks in custom formatting is scaling large numbers.
When Tableau displays values in thousands, millions or billions, the scaling is actually controlled by commas within the format string it uses. The same trick can be applied in custom format strings:
| Format | Meaning |
|---|---|
#,##0
|
Normal number with thousands separators |
#,##0,
|
Divide by 1,000 |
#,##0,,
|
Divide by 1,000,000 |
#,##0,,,
|
Divide by 1,000,000,000 |
The letters K, M and B are simply text added afterwards.
For example:
#,##0.0,,"M"
means:
- Divide the value by 1,000,000
- Show one decimal place
- Add the letter M
| Value | Result |
|---|---|
| 1,250,000 | 1.3M |
| 25,000,000 | 25.0M |
Similarly:
#,##0.0,"K"
would display:
| Value | Result |
|---|---|
| 12,500 | 12.5K |
This gives you far more flexibility than simply selecting "Millions" from Tableau's standard formatting options.
As a quick word of warning, it's worth noting that if you set Display Units to Millions and then use a custom format that also divides by one million, the value will be scaled twice. If you find that your numbers aren't looking right when you try to use a custom number format, check this setting first.
For custom formats that include K, M or B values, it's usually safest to leave Display Units set to None and handle the scaling entirely within the format string.
To wrap up, I'll leave you with a reference for the common format symbols and some useful examples of custom number formats to help you put this into practise in your own work.
Common Format Symbols
| Symbol | Meaning | Example |
|---|---|---|
#
|
Optional digit |
123
|
0
|
Required digit |
005
|
.
|
Decimal point |
12.5
|
,
|
Thousands separator or scaling |
1,234 or ÷1000
|
%
|
Multiply by 100 and add % |
25%
|
;
|
Separate positive, negative, and zero formats |
Positive;Negative
|
"text"
|
Display literal text |
#" Customers"
|
()
|
Display values in brackets |
(1,234)
|
Useful Examples
| Format | Example Result |
|---|---|
£#,##0;(£#,##0)
|
(£1,250) |
#,##0;(#,##0);-
|
– |
#,##0" Customers"
|
125 Customers |
#,##0.0,"K"
|
12.5K |
£#,##0.0,,"M"
|
£1.2M |
0.0%
|
15.2% |
▲ 0.0%;▼ 0.0%;-
|
▲ 15.2%, ▼ 3.4%, – |
▲ £#,##0;▼ £#,##0;-
|
▲ £1,250, ▼ £500, – |
#,##0;(#,##0);"No Data"
|
No Data |
0.00E+00
|
Scientific notation |
