- 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
Syntax
custom_formats accepts either a string or a conditional object:
- String
- Conditional
Properties
custom_formats is a map of format definitions where each key is the format name. Names must be unique within the model.
- String
- Conditional
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 bothcustom_formats and constants enable reusability, they serve different purposes:
- Use
custom_formatswhen you need to define a complete format object that will be used across multiple fields - Use
constantswhen 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 measureformat parameters using either a plain string or explicit object syntax:
Plain string syntax (recommended):
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.- Use constants to add a unit suffix
- Use contstants to specify time and numeric formats with suffixes
Model file
View file