Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Not applicable

Reutilize master measure in another master measure in Qlik Sense

I've noticed that now you can use master measure in another master measure, eg.:

Meas. 1               TotalAmount              =       Sum(Amount)   

Meas. 2               TotalQty                    =        Sum(Qty)

Meas. 3                Average                    =       TotalAmount/TotalQty

If you put in a table all the three master measures they work fine, but if you remove Meas1 or Meas2 you have null in the Meas3 column.

The same apply if you use Meas3 alone.

Anyone has solved the issue?

thanks in advance

Tags (1)
1 Solution

Accepted Solutions

Re: Reutilize master measure in another master measure in Qlik Sense

You can't use master measures as if they are variables. The measures only make sense in the context of the object they're used. What you want instead is variables and use those. In Qlik Sense 2.1 you can create variables in the user interface. In older versions you need to create them in the script.

SET vTotalAmount = sum(Amount);

SET vTotalQty = sum(Qty);

LET vAverage = '$('& 'vTotalAmount)/$(' & 'vTotalQty)';

You can then use the variables in the measures:

=$(vTotalAmount)

=$(vTotalQty)

=$(vAverage)


talk is cheap, supply exceeds demand
4 Replies
alextimofeyev
Contributor II

Re: Reutilize master measure in another master measure in Qlik Sense

Hi,

you can can move measure definitions to variables:

Meas. 1   TotalAmount = $(vTotalAmount)

Meas. 2   TotalQty = $(vTotalQty)

Meas. 3   Average = $(vAverage)

Variables:

vTotalAmount = Sum(Amount)

vTotalQty= Sum(Qty)

vAverage = $(vTotalAmount)/$(vTotalQty)

Re: Reutilize master measure in another master measure in Qlik Sense

You can't use master measures as if they are variables. The measures only make sense in the context of the object they're used. What you want instead is variables and use those. In Qlik Sense 2.1 you can create variables in the user interface. In older versions you need to create them in the script.

SET vTotalAmount = sum(Amount);

SET vTotalQty = sum(Qty);

LET vAverage = '$('& 'vTotalAmount)/$(' & 'vTotalQty)';

You can then use the variables in the measures:

=$(vTotalAmount)

=$(vTotalQty)

=$(vAverage)


talk is cheap, supply exceeds demand
Not applicable

Re: Reutilize master measure in another master measure in Qlik Sense

Thanks for your reply, for end-users was easier to use Master Items instead of variables.

Anyway you (and Alex) are right.

Re: Reutilize master measure in another master measure in Qlik Sense

You can still use the Master Items. You just have to create them using the variables.


talk is cheap, supply exceeds demand