value_formats

LookML
Version

On this Page
Docs Menu

Go to Model Parameter List

Usage

-  value_formats: a name for your custom format
-  name: desired_name
1st
Tab
2nd
Tab
value_format: 'excel formatting string'
an excel-style formatting string

Definition

value_formats allows you to create custom, named formats that you can then apply to dimensions and measures by using the value_format_name parameter

When using value_formats, the value that you provide in the name parameter should not have spaces, and will be the name you use to refer to your custom format. The value that you provide in the value_format parameter should be an Excel-style format that defines the custom formatting you want. You can define more than one custom format, as shown below in the examples.

You can read Excel’s complete guide about how to specify these formats in their documentation. 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 here (please note some special characters, such as international currency symbols, must be enclosed in double quotes):

value_format: '0' # Integer (123) value_format: '*00#' # Integer zero-padded to 3 places (001) value_format: '0 " String"' # Integer followed by a string (123 String) # Please note "String" can be replaced with any other word value_format: '0.##' # Number up to 2 decimals (1. or 1.2 or 1.23) value_format: '0.00' # Number with exactly 2 decimals (1.23) value_format: '*00#.00' # Number zero-padded to 3 places and exactly 2 decimals (001.23) value_format: '#,##0' # Number with comma between thousands (1,234) value_format: '#,##0.00' # Number with comma between thousands and 2 decimals (1,234.00) value_format: '0.000,," M"' # Number in millions with 3 decimals (1.234 M) # Please note division by 1 million happens automatically value_format: '0.000," K"' # Number in thousands with 3 decimals (1.234 K) # Please note division by 1 thousand happens automatically value_format: '$0' # Dollars with 0 decimals ($123) value_format: '$0.00' # Dollars with 2 decimals ($123.00) value_format: '"€"0' # Euros with 0 decimals (€123) value_format: '$#,##0.00' # Dollars with comma btwn thousands and 2 decimals ($1,234.00) value_format: '$#.00;($#.00)' # Dollars with 2 decimals, positive values displayed # normally, negative values wrapped in parenthesis value_format: "0%" # Convert to percent with 0 decimals (.01 becomes 1%) value_format: "0.00%" # Convert to percent with 2 decimals (.01 becomes 1.00%)

Looker has several built-in value formats already available:

Name Example
id 1234
decimal_0 1,234
decimal_1 1,234.5
decimal_2 1,234.56
decimal_3 1,234.567
decimal_4 1,234.5678
Name Example
usd_0 $1,234
usd $1,234.56
gbp_0 £1,234
gbp £1,234.56
eur_0 €1,234
eur €1,234.56

Looker also has built-in percentage formats. For percentage formats, Looker takes the underlying decimal value and multiplies it by 100 to get a percentage. The examples below start with the underlying value “0.123456”:

Name Example
percent_0 12%
percent_1 12.3%
percent_2 12.34%
percent_3 12.345%
percent_4 12.3456%

Examples

Create a custom format called euro_in_thousands that looks like €1.23K:

- value_formats: - name: euro_in_thousands value_format: '"€"0.000," K"'

Create a custom format called usd_in_millions that looks like $1.23M and a format called phone_number that looks like (123) 456-7890:

- value_formats: - name: usd_in_millions value_format: '$0.000,," M"' - name: phone_number value_format: '(###) ###-####'

Still have questions?
Go to Discourse - or - Email Support
Top