Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 😞
You cannot use a master item within an aggregation function. In your post, Sum(calculation_measure) is not allowed.
-Rob
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'
)))
@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.
I changed the domain names when I added it here for clarity, the screenshot shows the original version.
Have to dive deep to check, try square brackets
You cannot use a master item within an aggregation function. In your post, Sum(calculation_measure) is not allowed.
-Rob