# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

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)

Amijit

1 Solution

Accepted Solutions
Highlighted
MVP

## 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
MVP

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

New Contributor III

## Re: Multiple variables in Set Analysis

Hi Ruben,

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
MVP

## 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.

New Contributor III

## Re: Multiple variables in Set Analysis

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

Honored Contributor III