Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jcampbell
Partner - Creator
Partner - Creator

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.

Labels (1)
1 Solution

Accepted Solutions
JonnyPoole
Former Employee
Former Employee

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.

View solution in original post

4 Replies
JonnyPoole
Former Employee
Former Employee

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
Partner - Creator
Partner - Creator
Author

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!

JonnyPoole
Former Employee
Former Employee

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
Partner - Creator
Partner - Creator
Author

That worked perfectly. Thanks for the suggestion!