Skip to main content
Custom formats are format objects that can be defined once in a model file and referenced throughout your model. Unlike constants, which hold string values, custom formats are complete format objects that can include conditional logic, named formats, Excel-style strings, and other format features. Custom formats are resolved when formatting values in queries and visualizations, making them ideal for format patterns that need to be centrally managed and consistently applied across multiple fields. For example:
  • Complex conditional formats that vary based on field values
  • Format patterns that include named formats or custom strings
  • Formats that need to be maintained in a single location and used across multiple dimensions or measures
Custom formats are also inherited by shared extension models.

Syntax

custom_formats accepts either a string or a conditional object:

Properties

custom_formats is a map of format definitions where each key is the format name. Names must be unique within the model.
string
required
The format definition. This can be any valid format type:
  • A named format (e.g., currency_2, percent_1)
  • An Excel-style string (e.g., '#,##0.00 "kg"')
  • A reference to another custom format

Difference from constants

While both custom_formats and constants enable reusability, they serve different purposes:
  • Use custom_formats when you need to define a complete format object that will be used across multiple fields
  • Use constants when you need a reusable string value that might be used in format strings or other contexts

Referencing custom formats

Once defined in the model file, custom formats can be referenced in dimension and measure format parameters using either a plain string or explicit object syntax: Plain string syntax (recommended):
Explicit object syntax:
The plain string syntax is the recommended approach — it’s cleaner and more concise.

Examples

Named format reference

Define custom formats that reference built-in named formats:
Model file
View file

Excel-style strings

Define custom formats with Excel-style strings:
Model file
View file

Conditional formats

Define custom formats with conditional logic that selects different formats based on field values:
Model file
View file

Combining custom formats with model constants

Custom formats can reference model constants to create even more flexible formatting patterns.
Model file
View file