Rather than having to change my number formatting each time I use a field in a report, it would be preferable to set the default formatting at the model level instead.
This will save huge amount of time, but also ensure consistent formatting & styles get applied
An example of how this might look in;
dimension item_code {
label: 'Item Code'
type: 'number'
hidden: false
definition: @sql {{ #SOURCE.item_code }};;
default_format: "#,##0.00"
}
measure system_accuracy {
label: "System Accuracy"
type: "number"
definition: @sql cast(sum( {{ is_good_alert }} ) as numeric(16,4))/
sum({{ is_good_alert }} + {{ is_bad_alert }});;
hidden: false
default_format: "0.0%"
}
It could even go one step further, and define formats in a separate document, and then specify that format within the schema, eg…
style perc_1dec {
format: "0.0%"
}
style number_2dec {
format: "#,##0.00""
}
.
dimension item_code {
label: 'Item Code'
type: 'number'
hidden: false
definition: @sql {{ #SOURCE.item_code }};;
default_format: number_2dec
}
measure system_accuracy {
label: "System Accuracy"
type: "number"
definition: @sql cast(sum( {{ is_good_alert }} ) as numeric(16,4))/
sum({{ is_good_alert }} + {{ is_bad_alert }});;
hidden: false
default_format: perc_1dec
}
The advantage of the latter approach is you can then update all default percentages from 1dp to 2dp instantly, for example.