Qlik Community

Qlik Sense App Development

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

jcampbell
Contributor

Master Library & Measures

Does anyone know if it's possible to use or reference a measure in the Master Items / Library in another measure? For example, I have a measure in the library that calculates a total spend from various products. I'd like to create another measure that uses this but it would be easier / better to simply be able to add something like Sum([Products_Total]) with "Products_Total" being my library measure.

Any suggestions would be greatly appreciated.


Thanks.

1 Solution

Accepted Solutions
Employee
Employee

Re: Master Library & Measures

Joshua , i'm thinking something like this. Its a guess without working with your app.

Sum( [Book Rate (Hotel)]  * Nights * Guests)

/

Sum( TOTAL [Book Rate (Hotel)]  * Nights * Guests)


If this works , then you can take the denominator or numerator 'as is' and set it in a variable in the load, reload and then update the expression to invoke the variable instead.

4 Replies
Employee
Employee

Re: Master Library & Measures

You can't reference another measure from the formula of a different measure.

But what you can do is save the expression as a variable in the load editor using the SET script command as follows

ex: 

Set vSales='sum(Sales)' ;

And then be able to use the variable in the formula of a measure. Just make sure to use the dollar sign expansion syntax as follows to invoke the string of characters within the variable as a dynamic expression

ex:

sum(Costs) /  $(vSales)

jcampbell
Contributor

Re: Master Library & Measures

Thanks for the quick reply Jonathan. I'm having an issue with this. I got the measure stored in a variable called "vHotelCost". My expression or measure is "Sum([Book Rate (Hotel)]) * Sum(Nights) * Sum(Guests)". So I tried using the following measure in my bar chart to display the percent of spend in each hotel city:

Sum([Book Rate (Hotel)]) * Sum(Nights) * Sum(Guests) /  $(vHotelCost)

That did not work. So I tried the following:

Sum([Book Rate (Hotel)]) * Sum(Nights) * Sum(Guests) / Sum(Total $(vHotelCost))

That did not work either. Any suggestions?

Thanks!

Employee
Employee

Re: Master Library & Measures

Joshua , i'm thinking something like this. Its a guess without working with your app.

Sum( [Book Rate (Hotel)]  * Nights * Guests)

/

Sum( TOTAL [Book Rate (Hotel)]  * Nights * Guests)


If this works , then you can take the denominator or numerator 'as is' and set it in a variable in the load, reload and then update the expression to invoke the variable instead.

jcampbell
Contributor

Re: Master Library & Measures

That worked perfectly. Thanks for the suggestion!

Community Browser