Qlik Community

Qlik Sense App Development

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

Highlighted
shempgracie
New Contributor III

Set expression with multiple filters and a variable not working

Hi All,

I have a scatter plot and I want the user to be able to pick 2 points from the scatter plot, and then have 2 pie charts reflect the market share of each point that was selected (so they can compare market share at point 1 vs market share at point 2).

I have a variable that grabs the point that was selected from the scatter plot (it's called PICK2).

When I use the below expression, and hard code the PLAN that was selected, it works.  When I use the variable, it does not.

Does anyone know how to convert this to use my variable instead of hardcoding it?

This works with hardcoding:

avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2, PlanName={'Acme Plan'} >}MarketSharePercent)

This does not work with my variable:

avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2, PlanName=$(Pick2) >}MarketSharePercent)

 

Thank you in advance!

MNike

9 Replies
Partner
Partner

Re: Set expression with multiple filters and a variable not working

It should work.
You need to make sure that the output of $(Pick2) is {'Acme Plan'} and not only 'Acme Plan'.
???
Celebrating my 300 accepted solution in the Qlik Community
???

Re: Set expression with multiple filters and a variable not working

May be try this

Avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2, PlanName = {'$(Pick2)'} >} MarketSharePercent)
shempgracie
New Contributor III

Re: Set expression with multiple filters and a variable not working

Ok that may be my problem.  Right now Pick2 is:   Acme Plan.

How can I get my variable to format as {'Acme Plan'}, or how can I change my set expression to handle that?

 

Thank you!

Mike

 

shempgracie
New Contributor III

Re: Set expression with multiple filters and a variable not working

I tried this, but unfortunately my pie chart was still blank.

Any other thoughts?

Mike

Partner
Partner

Re: Set expression with multiple filters and a variable not working

vPick2 = '{'& Concat(DISTINCT Chr(39) & Pick2 & Chr(39), ', ') & '}';

???
Celebrating my 300 accepted solution in the Qlik Community
???
shempgracie
New Contributor III

Re: Set expression with multiple filters and a variable not working

Ok I think we're getting closer! I formatted my variable the way you described.  Now its like this:

Pick2 = {'Acme'}

This continues to work when hardcoded, but still doesn't work with the Pick2 variable.

avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2, PlanName={'Acme'} >}MarketSharePercent)

I've tried every combination of PlanName=Pick2, PlanName=$(Pick2), etc. and my pie chart is still blank.

Any other ideas what I'm doing wrong?

Mike

 

 

shempgracie
New Contributor III

Re: Set expression with multiple filters and a variable not working

...and a little more info that may help:

 

My Pick2 variable now looks like this:

Pick2='{'& Concat(DISTINCT Chr(39) & SubField(GetFieldSelections(PlanName),',',2) & Chr(39), ', ') & '}';

Any help would be greatly appreciated!

Mike

 

 

Partner
Partner

Re: Set expression with multiple filters and a variable not working

Do I understand correctly that the SET modifier

PlanName=$(Pick2)

should set PlanName to all selected PlanName?

This is default behavior in Qlik Sense. Can't you just use the expression without the PlanName modifier?

avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2>}MarketSharePercent)

 

???
Celebrating my 300 accepted solution in the Qlik Community
???

Re: Set expression with multiple filters and a variable not working

If this is what it is, why don't you just use this

Avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2, PlanName = P(PlanName)>}MarketSharePercent)

or this

Avg({<myFilter1=$::myFilter1, myFilter2=$::myFilter2, PlanName = $::PlanName>}MarketSharePercent)