Data Format
Knowledge Checkpoint
A grasp of these concepts will help you understand this documentation better:
You can format AML fields to improve readability for your reports. This section will help you define a Data-Format-As-Code using AML.
Available formats by data type:
| Data type | AML format |
|---|---|
| Number | Number Format |
| Date | Date Format |
| Datetime | No data format. Set type: "date" to use Date Format |
| Text | String and HTML, on viz fields only |
| True/False | No data format |
High-level concept
A field's display is made of two parts: its data type and its data format. The type decides which formats are available to the field, and the format decides how its values are rendered. If your pattern is invalid, Holistics will fall back to the default format to render your data.
To format an AML dimension/measure, add a format property containing a format pattern to its definition:
Model public_accounts {
type: 'table'
label: 'Accounts'
table_name: '\"public\".\"Accounts\"'
data_source_name: "piggy_bank"
dimension balance {
label: "Balance"
definition: @sql {{ #SOURCE.balance }};;
hidden: false
type: "number"
format: "#,###0.00,,\"M\""
}
}
Apply data format
You can set the type and the format at two levels:
- Model and dataset fields: A format defined here makes every viz that references the field inherits it, so users only need define it once instead of per chart.
- Viz fields: By default, viz fields inherit format from modeing. When a single chart should look different, add a
formatthere to override for that chart only.
For the patterns each type accepts, see Number Format and Date Format.