Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
amijit_hazarika
Contributor III
Contributor III

Multiple variables in Set Analysis

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

1 Solution

Accepted Solutions
rubenmarin

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.

View solution in original post

5 Replies
rubenmarin

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))

amijit_hazarika
Contributor III
Contributor III
Author

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

rubenmarin

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.

amijit_hazarika
Contributor III
Contributor III
Author

Thanks Ruben. There was a typo for which it wasn't working.

sasiparupudi1
Master III
Master III

Please close this thread by marking a correct answer