Derived Measure
Derived measures is a special method to easily create complex measures based on existing measures. It's called Derived Measure. It is meant to be used for measures that are very similar and are related to a main measure. Like YTD, PY and also custom variants that can be defined by you and your specific wishes. In other solutions, you are forced to use all kind of obscure C# scripts, not with derived measures. It works as follows:
Imagine we have a measure like Revenue and a YTD is needed as well. Normally you would have added another measure with YTD syntax, now you can just add derived measure to Revenue and set it to the template for YTD. The template is defined in the measuretemplates.yaml. It's especially beneficial if you have a lot of YTD measures, than you can just type this in the model.yaml, and you have YTD measure for basic measure:
- Name: Revenue
Expression: |
CALCULATE (SUMX(Finance, [Revenue])
DerivedMeasures:
- DerivedMeasure: YTD
The name for the new measure is automaticly set from the template. In the template the 0 is the placeholder where the name of the parent measure is filled in.
- DerivedMeasure: YTD
MeasureName: "{0} YTD"
Expression: "TOTALYTD([{0}], Kalender[Datum], All(Kalender))"
It's also possible to override the name for a given derived measure as follows:
- Name: Revenue
Expression: |
CALCULATE (SUMX(Finance, [Revenue])
DerivedMeasures:
- DerivedMeasure: YTD
Name: Rev Year To Date with custom name
It is still possible to override also other settings as well. So if we want to set a measure to hidden, we can just define IsHidden: true. Default it will get the setting from the parent measure. Same for formatstring and other options as well.