Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
mendoncart
Not applicable

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
Not applicable

Re: Set Analysis with multiple value variable

May be enter like this

1, 3

and then use it like this

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

7 Replies
sunny_talwar
Not applicable

Re: Set Analysis with multiple value variable

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
Not applicable

Re: Set Analysis with multiple value variable

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
Not applicable

Re: Set Analysis with multiple value variable

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

mendoncart
Not applicable

Re: Set Analysis with multiple value variable

That is exactly what I wanna know!

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

sunny_talwar
Not applicable

Re: Set Analysis with multiple value variable

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
Not applicable

Re: Set Analysis with multiple value variable

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
Not applicable

Re: Set Analysis with multiple value variable

Comma is replaced with ','

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