@{constant_name} syntax.
Constants are resolved before other template processing (Mustache and field references) when a query executes or a link renders, making them ideal for values that need to be centrally managed and consistently applied across your model. For example:
- Database schema names that may differ between environments
- Common URL patterns for data links
- Repeated string values that you want to maintain in a single location
- Configuration values that can be dynamically referenced
- Reusable AI context blocks that can be referenced in
ai_contextfields
Syntax
Properties
A map of constant definitions where each key is the constant name. Names must be unique within the model.
Examples
Dynamic schema reference
Use constants to reference schema names that may vary across environments. Define the constants in the model file:Model file
View file
Dynamic links with field references
Create link patterns that include field references. Define the constants in the model file:Model file
Dimensions in a view
Reusable format patterns
Constants are often used with theformat parameter on dimensions and measures. Reference a constant with @{constant_name} inside the format string (including inside conditional format branches).
For standard currency and number display, use a named format like
usdcurrency_2 or percent_1 directly. Constants are most valuable for custom Excel-style patterns that appear in several fields.Model file
View file
Reusable AI context
Constants can be referenced inai_context fields at the model, topic, view, and sample query levels. This allows you to maintain shared instruction blocks in a single location instead of duplicating them across multiple ai_context fields.
Model file
Topic file
Unknown constant references (e.g.,
@{undefined_constant}) render as-is rather than failing. Model validation will display warnings when an ai_context field contains unknown constant references.
