Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

amijit_hazarika
New 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
Highlighted

Re: Multiple variables in Set Analysis

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.

5 Replies

Re: Multiple variables in Set Analysis

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
New Contributor III

Re: Multiple variables in Set Analysis

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

Highlighted

Re: Multiple variables in Set Analysis

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
New Contributor III

Re: Multiple variables in Set Analysis

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

sasiparupudi1
Honored Contributor III

Re: Multiple variables in Set Analysis

Please close this thread by marking a correct answer