Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mendoncart
Contributor III
Contributor III

Set Analysis with multiple value variable

Hi!

I have a sum using set analysis, but one of the criteria is this: BPLId={'$(Branch)'}

Where Branch is a variable that currently contain the number 1.

But I'd like to be able to use two value: 1 and 3.

I know if I make my set analysis criteria like BPLId={'1,3'} it works, but I cant figure out how to make it work using the variable instead.

Maybe I have to set the values in the variable with some kind of concatenation?

And I should mention that this variable is created manually on the app variables menu, not in the script.

Can anyone shed a light on this?

1 Solution

Accepted Solutions
sunny_talwar

May be enter like this

1, 3

and then use it like this

BPLId = {$(=Chr(39) & Replace(Branch, ',', Chr(39) & ',' & Chr(39)) & Chr(39))}

View solution in original post

7 Replies
sunny_talwar

It needs to have single quotes around individual Branch

BPLId={'1,3'} -> Incorrect

BPLId={'1', '3'} -> Correct


What is your variable Branch expands to?

mendoncart
Contributor III
Contributor III
Author

Oh, I'm sorry. You are right, {'1','3'} is correct.

Well, my variable is simple just storing the number 1.

I've tried several forms to combine two values, but no success...

Print of my variable:

Qlik Sense Desktop_2.jpg

sunny_talwar

How do you intend to enter the two values? can you show us this?

mendoncart
Contributor III
Contributor III
Author

That is exactly what I wanna know!

How to enter two values in the variable to reflect on the set analysis.

sunny_talwar

May be enter like this

1, 3

and then use it like this

BPLId = {$(=Chr(39) & Replace(Branch, ',', Chr(39) & ',' & Chr(39)) & Chr(39))}

mendoncart
Contributor III
Contributor III
Author

It worked like a charm! Thank you so much!

Just to see what is going on, this formula inserts single quotes with Chr(39) and replace the comma with comma and quotes, closing the end with another quote. Right?

If so, I'll be able to use as much values inside my variable as I may need.

Well, thanks again for all your support!

sunny_talwar

Comma is replaced with ','

So 1, 3 is becoming '1', '3'. Similarly, 1, 3, 5 will become '1', '3', '5'