User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
  
English
Français
Deutsch
日本語
named_value_format

Usage

named_value_format: desired_name {
  value_format: "excel formatting string"
}

Hierarchy

named_value_format

Default Value

None

Accepts

A name for your custom format, plus an Excel-style formatting string that defines the format

Definition

named_value_format enables you to create a custom, named format that you can then apply to dimensions and measures by using the value_format_name parameter.

When using named_value_format, the name that you provide 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.

The formatting used with the value_format parameter is the same as formatting used in the Value Format field in visualizations, except that the value_format parameter requires the formatting string to be enclosed in double quotes. See this page for information about value formats in visualizations.

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. Also, please note that some special characters, such as international currency symbols, must be enclosed in double quotes.

Some of the most common formatting options are shown here:

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\%" # Display as percent with 0 decimals (1 becomes 1%) value_format: "0.00\%" # Display as percent with 2 decimals (1 becomes 1.00%) 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%

When using one of the default formats, Looker rounds up or down to remove digits, rather than truncating values. When a default format name is used on a measure, rounding occurs after the measure has been aggregated.

Examples

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

named_value_format: 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:

named_value_format: usd_in_millions { value_format: "$0.000,,\" M\"" } named_value_format: phone_number { value_format: "(###) ###-####" }

Top