Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ericdelaqua
Creator
Creator

Parse expression variable into Set analysis

Hello,

 

I have two variable define as below

vUserlist = Concat(distinct name,'|')

vUserfilter= SubField($(=vUserlist ),'|',$1)

 

the default meseare is sum(sales)

 

I would like to sum sales where for specific names based on a dynamic list. this is because we have an exact number of names and would like to have differenct charts for each name without using Qlik's Trellis which doesn't work properly.

I have tried Sum({<name={"$(vUserfilter(1))"}>}sales) but it is not working.

Any suggestion how I can make this work?

Labels (4)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

I've tested as below and it works

vList

=concat(distinct ID,'|')   <--with leading = sign

vFilter

=concat(distinct Year,'|')   <--with leading = sign

 

My Expression

count({<ID={"$(vFilter(1))"}>} Number)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

6 Replies
vinieme12
Champion III
Champion III

pretty close, just add the single quotes

 

vUserfilter= SubField('$(=vUserlist )','|',$1)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

Side note, selected values will not be concatenated in the order of selection, and there is no workaround to do so

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ericdelaqua
Creator
Creator
Author

@vinieme12 

I tried it but still it is returning the total for all names. see the sample code below.

testtable:
Load * Inline [Year,name,sales
2010,frank,2000
2010,eric,2500
2011,frank,7000
2011,eric,7500
2012,frank,3000
2012,eric,3500
2013,frank,4000
2013,eric,4500
];

Bar chart

dimension is Year

Measure is 

Sum({<name={"$(vUserfilter(1))"}>}sales)

Variables 

ericdanqua_0-1652941356399.png

 

ericdelaqua
Creator
Creator
Author

Hi,

I have switched my variable to be 

vPickName = Pick(1, $(=Concat(distinct Chr(39) & name & Chr(39), ', ')))

and Sum({<name={"$(vPickName)"}>}sales)  Works fine 

BUT to make it dynamic so I can parse the pick number I used

vPickName = Pick($1, $(=Concat(distinct Chr(39) & name & Chr(39), ', ')))

Sum({<name={"$(vPickName(2))"}>}sales)  and it doesn't work.

Please what am I am missing?  it seems Pick doesn't allow parsing a variable as the number?

 

vinieme12
Champion III
Champion III

define the variables with a leading  = (equal sign)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

I've tested as below and it works

vList

=concat(distinct ID,'|')   <--with leading = sign

vFilter

=concat(distinct Year,'|')   <--with leading = sign

 

My Expression

count({<ID={"$(vFilter(1))"}>} Number)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.