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

Usage

view: view_name {
  dimension: field_name {
    value_format_name: format_name
  }
}

Hierarchy

value_format_name

Possible Field Types

Dimension, Measure

Accepts

One of the default value formats listed below, or the name of a format you created with the named_value_format parameter

Definition

The value_format_name parameter enables you to format data values using formats built into Looker or your own custom, reusable formats. If you want to apply an Excel-style format directly to a unique field, use value_format instead.

The value_format_name parameter can be used on both dimensions and measures. For example:

measure: total_order_amount { type: sum sql: ${order_amount} ;; value_format_name: usd }

Default Format Names

Looker has the default formats shown in the tables below. 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.

You can also create your own named formats by using the named_value_format parameter.

Numeric Formats

The default formats for numeric field types are:

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

For numeric field types, id should only be used on numbers that have 16 digits or fewer. Beyond 16 digits, id may round results. For numbers with more than 16 digits, cast them as a string and use id on the string field type.

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%

Common Challenges

Using value_format_name with the number_format User Attribute

If you use value_format_name to format fields in your models, the number format selected in the number_format user attribute is applied on top of the format given with value_format_name. For an example, and to learn more, visit the Localizing Looker documentation page.

Top