Master item measures are measures saved for later use in Qlik Sense. The measures can be added to visualisations directly, but they can also be used in expressions to calculate other measures. This article will explain how to reference master measures in expressions.

How to reference master item measures

Consider this table showing visitor sessions for a small blog by month and year.

The expressions calculating the sessions for last year and this year are as follows, respectively:

sum({<[Date.Calendar.Year] = {"$(=Year(AddYears(Today(),-1)))"}>} [GA Sessions])

sum({<[Date.Calendar.Year] = {"$(=Year(Today()))"}>} [GA Sessions])

If we wanted to add an additional column calculating the year on year change, this is the expression we would write:

(sum({<[Date.Calendar.Year] = {"$(=Year(Today()))"}>} [GA Sessions])
-
sum({<[Date.Calendar.Year] = {"$(=Year(AddYears(Today(),-1)))"}>} [GA Sessions]))
/
sum({<[Date.Calendar.Year] = {"$(=Year(AddYears(Today(),-1)))"}>} [GA Sessions])

To make life easier, the measures for sessions last year and this year could be added to master items. We could then refer to those master items when calculating the YoY change. The YoY change expression becomes:

("Sessions This Year" - "Sessions Last Year")/ "Sessions Last Year"

Note that this measure can be stored as a master item. Measure master items can thus be nested.

Tips for referencing measure master items successfully

To use this technique successfully, there are a few important things to remember:

  • Master measure names do not automatically appear when you type them, so ensure you enter the name exactly as it appears in the list of master item measures. If you do this correctly, it will be purple.
  • Refer to master measure by its name, NOT label.
  • If your master measure has a name identical to a field, Qlik may assume you’re referring to the field. Avoid using identical names.
  • To successfully nest master item measures, DO NOT start any of the expressions with an equals sign. This will cause an error when referencing the master measure.
  • The master measure result is not stored but calculated on the fly. Thus, it will be aggregated by the dimensions included in the visualisation.
  • You cannot refer to master measures in a dimension unless you use the Aggr function as usual.