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 lets you 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 following tables. 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 shown below. They start with the underlying value "0.123456789":

Name Example
decimal_0 1,235
decimal_1 1,234.6
decimal_2 1,234.57
decimal_3 1,234.568
decimal_4 1,234.5679
usd_0 $1,235
usd $1,234.57
gbp_0 £1,235
gbp £1,234.57
eur_0 €1,235
eur €1,234.57
id 1235

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.35%
percent_3 12.346%
percent_4 12.3456%

Things to know

To apply value_format_name to a field, the type parameter must be defined for that field.

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, see the Localizing number formatting documentation page.