Qlik Community

Qlik Sense App Development

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

Employee
Employee

Using GetFieldSelections in Set Analysis

Hi everyone,

My eyes are going crossed trying to figure this out. Please help!

I have a filter pane (Occupation) that I want to use to dynamically create a set analysis filter.

The following set statement is successful if I only select ONE value from my Occupation filter:

    

     count({<Occupation ={"$(=GetFieldSelections(Occupation,','))"}>}EMPLOYEE_COUNTER)


However, if I select more than one value then it can't evaluate successfully because the filter string that's built is missing quotes (' ')....so I added the Chr(39) below but can't get it to work at all now

     count({<Occupation ={"$(=Chr(39)&GetFieldSelections(Occupation,Chr(39)& ','&Chr(39))&Chr(39))"}>}EMPLOYEE_COUNTER)

The goal is to have a statement that looks like the follows after the user selects 'Doctor', 'Nurse', and 'Firefighter' from the Occupation filter.

count({<Occupation = {'Doctor','Nurse','Firefighter'}>}EMPLOYEE_COUNTER)

Or if you can think of a better way to do it in general than what I'm doing, I'm all ears as well.

Thanks in advance!

1 Solution

Accepted Solutions
vinieme12
Esteemed Contributor II

Re: Using GetFieldSelections in Set Analysis

But why do you even need to add set analysis for that?

Showing associated data based on selections is Natural behavior you don't need set analysis for that??

If you still need set analysis try using  P ()   , but I must re-iterate this is not required

Example

count({<Occupation = P (Occupation)>}EMPLOYEE_COUNTER)



To concat selections try below in textbox


=$(=chr (39)&concat (distinct fieldname, chr(39)&','&chr(39))&chr(39))

5 Replies
yddona_lyn
New Contributor III

Re: Using GetFieldSelections in Set Analysis

Hi,

You can try this: (i removed the excess " ")

=count({<Occupation={$(=chr(39)&GetFieldSelections(Occupation,chr(39)&','&chr(39))&chr(39))}>}EMPLOYEE_COUNTER)

vinieme12
Esteemed Contributor II

Re: Using GetFieldSelections in Set Analysis

But why do you even need to add set analysis for that?

Showing associated data based on selections is Natural behavior you don't need set analysis for that??

If you still need set analysis try using  P ()   , but I must re-iterate this is not required

Example

count({<Occupation = P (Occupation)>}EMPLOYEE_COUNTER)



To concat selections try below in textbox


=$(=chr (39)&concat (distinct fieldname, chr(39)&','&chr(39))&chr(39))

vishalwaghole
Valued Contributor II

Re: Using GetFieldSelections in Set Analysis

You can try below expression,

=if(isNull(GetFieldSelections(Occupation)),0,sum(employee_count))

Then try by selecting occupation one by one.

Employee
Employee

Re: Using GetFieldSelections in Set Analysis

Thanks so much Vineeth! I knew someone would ask why I even need this because it's natural behavior....ha. I'm going to be working with the Occupation field as a data island to build the filter string to apply elsewhere for a calculation. Anyway, using the P function did the trick and is much simpler! Thanks so much.

Employee
Employee

Re: Using GetFieldSelections in Set Analysis

Hi Yddona - thanks for your response - this worked as well. I just needed to remove the " ". It's always the small things that get you!