Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Qlik Experts,
I am trying the below expression but it's not working.
Any guidance would be very helpful.
If($(variable1) = 0,0, ($(variable2) - $(variable1)) / $(variable2))
Variable1 = Sum({<Field = {XYZ}>} Amount)
Variable2 = Sum({<Field = {ABC}>} Amount2)
Thanks in Advance
Amijit
The 3rd expression I just copied and pasted to content of each variable, if the expression works it should work.
If doesn't works it can be because:
- The variable content has a starting equal sign '=Sum(...'. It shouldn't be there, just 'Sum(...'
- Some typo? variable names are case sensitive, 'variable1' is not the same than 'Variable1'
- The set analysis is more complex than the example...I will need a sample to check.
Hello Amijit, seems it should work, mybe you can try adding simple quotes in set analysis:
Sum({<Field = {'XYZ'}>} Amount)
Or adding the variable expressions as table expressions to check the values returned and the final expression:
- Sum({<Field = {XYZ}>} Amount)
- Sum({<Field = {ABC}>} Amount2)
- If(Sum({<Field = {XYZ}>} Amount) = 0,0, (Sum({<Field = {ABC}>} Amount2) - Sum({<Field = {XYZ}>} Amount)) / Sum({<Field = {ABC}>} Amount2))
Hi Ruben,
Thanks for your quick response.
It works when I try the set analysis directly but it gives 0 when I use variables.
If($(variable1) = 0,0, ($(variable2) - $(variable1)) / $(variable2)) : I dont get data for this.
Thanks
Amijit
The 3rd expression I just copied and pasted to content of each variable, if the expression works it should work.
If doesn't works it can be because:
- The variable content has a starting equal sign '=Sum(...'. It shouldn't be there, just 'Sum(...'
- Some typo? variable names are case sensitive, 'variable1' is not the same than 'Variable1'
- The set analysis is more complex than the example...I will need a sample to check.
Thanks Ruben. There was a typo for which it wasn't working.
Please close this thread by marking a correct answer