Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Milaf
Contributor III
Contributor III

How to call "Master Item" into a formula?

Hello, I developed the formula below to calculate according to the period selection on the frontend. Is there any way to call Master Item to this formula?

=if(GetFieldSelections([Period])='Daily',avg({<Today_T= {'$(vYesterday)'}>} [calculated_masteritem]),
if(GetFieldSelections([Period])='Weekly',avg({<Today_T= {'$(vPreviousWeek)'}>} [calculated_masteritem]),
if(GetFieldSelections([Period])='Monthly', avg({< Monthly = {'$(vMonthly)'}>} [calculated_masteritem])
)))

The syntax seems correct but result 0 returning 😞

 

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You cannot use a master item within an aggregation function. In your post, Sum(calculation_measure) is not allowed. 

https://help.qlik.com/en-US/sense/August2023/Subsystems/Hub/Content/Sense_Hub/Expressions/references...

-Rob

View solution in original post

4 Replies
Aasir
Creator III
Creator III

Your formula looks correct.
Ensure that the Master Item [calculated_masteritem] is working as expected independently. You can test it by directly using this Master Item in a chart or table to verify that it produces the desired values.
Double-check the values of your variables (vYesterday, vPreviousWeek, vMonthly) to make sure they are being set correctly and are valid dates.
You can add temporary variables or text boxes in your Qlik Sense app to display the values of your variables and selections. This can help you debug and understand what values are being used in your calculations.

Below is a modified version of your formula with additional labels for each condition, which might help you identify the issue:

=if(GetFieldSelections([Period])='Daily',
avg({<Today_T= {'$(vYesterday)'}>} [calculated_masteritem]),
if(GetFieldSelections([Period])='Weekly',
avg({<Today_T= {'$(vPreviousWeek)'}>} [calculated_masteritem]),
if(GetFieldSelections([Period])='Monthly',
avg({< Monthly = {'$(vMonthly)'}>} [calculated_masteritem]),
'Invalid Period Selection'
)))

Milaf
Contributor III
Contributor III
Author

@Aasir  Thank you for the answer, but the variables and calculations work separately. It works when I add a field from the data instead of the master item. Master Item also brings the correct result, but it does not work when I call it to the formula.

Gamze__1-1700552760213.png

 



I changed the domain names when I added it here for clarity, the screenshot shows the original version.

 

Aasir
Creator III
Creator III

Have to dive deep to check, try square brackets

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You cannot use a master item within an aggregation function. In your post, Sum(calculation_measure) is not allowed. 

https://help.qlik.com/en-US/sense/August2023/Subsystems/Hub/Content/Sense_Hub/Expressions/references...

-Rob