For Looker developers: The formatting shown on this page is the same as formatting used with the
value_format
LookML parameter, except that thevalue_format
parameter requires the formatting string to be enclosed in double quotes.
Custom formatting gives you greater control over how numeric data appears in a Looker result set. With custom formatting, you can apply Excel-style formatting options to numeric data shown in visualizations, or produced by custom fields or table calculations.
Custom formatting is supported only for dimensions of
type: number
or measures oftype: number
.
Using custom formatting in visualizations
For visualizations with a Values tab in the gear menu:
- Click on the visualization’s gear menu.
- Select the Values tab.
- In the Value Format field, enter the custom formatting string.
For table visualizations:
- Click on the visualization’s gear menu.
- Select the Series tab.
- In the Format field under Customizations, expand the drop-down menu and select Custom at the bottom of the menu.
A new blank field will appear once you select Custom. Enter the custom formatting string in the blank field:
Using custom formatting with table calculations and custom fields
When you create or edit a table calculation or custom field, select Custom in the formatting drop-down and enter the custom format in the blank field:
Custom formatting examples
You can read Excel’s complete guide to specifying these formats in their documentation, or use a third-party tool to build a custom format, such as Custom Formats Builder. However, at this time, date formatting, color formatting, and hexadecimal conversion are not supported in Looker.
Some of the most common formatting options are shown below. A format code using 0
requires that non-significant zeros be displayed if the number contains fewer digits than specified in the code. A format code using #
only displays significant digits, even if there are fewer digits than specified in the code.
Some special characters, such as international currency symbols, must be treated as strings and enclosed in double quotes.
Excel-style formatting does not support many international number formats, such as 1.234,56 or 1 234,56. Looker does support several international formats through the localization function. For information about localizing number formats, see the Localizing number formatting documentation page.
Format | Result |
---|---|
0 | Integer (123) |
00# | Integer zero-padded to 3 places (001) |
0 "String" | Integer followed by a string (123 String)("String" can be replaced with any text string) |
0.## | Number up to 2 decimals (1. or 1.2 or 1.23) |
0.00 | Number with exactly 2 decimals (1.23) |
00#.00 | Number zero-padded to 3 places and exactly 2 decimals (001.23) |
#,##0 | Number with comma between thousands (1,234) |
#,##0.00 | Number with comma between thousands and 2 decimals (1,234.00) |
0.000,, "M" | Number in millions with 3 decimals (1.234 M)Division by 1 million happens automatically |
0.000, "K" | Number in thousands with 3 decimals (1.234 K)Division by 1 thousand happens automatically |
$0 | Dollars with 0 decimals ($123) |
$0.00 | Dollars with 2 decimals ($123.00) |
"€"0 | Euros with 0 decimals (€123) |
$#,##0.00 | Dollars with comma between thousands and 2 decimals ($1,234.00) |
$#.00;($#.00) | Dollars with 2 decimals, positive values displayed normally, negative values wrapped in parenthesis |
0\% | Display as percent with 0 decimals (1 becomes 1%) |
0.00\% | Display as percent with 2 decimals (1 becomes 1.00%) |
0% | Convert to percent with 0 decimals (.01 becomes 1%) |
0.00% | Convert to percent with 2 decimals (.01 becomes 1.00%) |