Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis with multiple selections

I have defined a set analysis as below in a Pivot Chart. It works fine when I have only one selection made for FIELD2 as I was using getfieldselections. FIELD2 is actually one of the dimensions. When I make multiple selections the output of getfieldselections(FIELD2) will be several values separated by comma like A,B,C


=Sum({$<FIELD1={'$(=getfieldselections(FIELD2))' }>} FIELD3)


It there a way to use set analysis to wildmatch the selections made for FIELD2 and get the sum?

15 Replies
sunny_talwar

Try this may be:

=Sum({$<FIELD1={"$(=Chr(34) & GetFieldselections(FIELD2, Chr(34) & ', ' & Chr(34)) & Chr(34))"}>} FIELD3)


=Sum({$<FIELD1={"$(=Chr(39) & GetFieldselections(FIELD2, Chr(39) & ', ' & Chr(39)) & Chr(39))"}>} FIELD3)

Not applicable
Author

Thanks for the response sunny, I have tried butt this doesnt work.

We are basically equating one value to multiple values

For example:

if FIELD1 is A and values selected for FIELD2 is A,B,C

Then the equation would be something like this.

A= 'A','B','C'  

Which is not a true statement.

sunny_talwar

Then I am not sure why you are trying to do that? What is the requirement here?

swuehl
MVP
MVP

I think the double quotes need to be removed from the set modifier.

=Sum({$<FIELD1={$(=Chr(39) & GetFieldselections(FIELD2, Chr(39) & ', ' & Chr(39)) & Chr(39))}>} FIELD3)

If you select A,B and C in FIELD2, this dollar sign expansion should evaluate to

=Sum({$<FIELD1={'A','B','C'}>} FIELD3)

I assume that is what you want? If not, please elaborate your requirement and post some sample field values for FIELD1 and FIELD2.

swuehl
MVP
MVP

Another option if you want to modify FIELD1 set, applying the FIELD2 set is

=Sum({$<FIELD1= FIELD2 >} FIELD3)

Not applicable
Author

Here is the requirement.

I have a pivot table with dimensions

FIELD0 and FIELD2

Expressions:

=Sum({$<FIELD1={'$(=getfieldselections(FIELD2))' }>} FIELD3)  --> Expression 1

=Sum({$<FIELD4={'$(=getfieldselections(FIELD2))' }>} FIELD5)  --> Expression 2


If I have one selection for FIELD2 (for example A)  the output would be

 

FIELD0FIELD2EXP1EXP2
123A3020


I am able to achieve the above with this formula

=Sum({$<FIELD1={'$(=getfieldselections(FIELD2))' }>} FIELD3)


but When I select more then one value for FIELD2 (for example A,B) I want my output to be


 

FIELD0FIELD2EXP1EXP2
123A3020
123B2528
142B3454


but the below formula doesnt work for me 

=Sum({$<FIELD1={$(=Chr(39) & GetFieldselections(FIELD2, Chr(39) & ', ' & Chr(39)) & Chr(39))}>} FIELD3)

because it is adding up everything and giving me result like below.


 

FIELD0FIELD2EXP1EXP2
123A89102
123B89102
142B89102


Was I clear?

sunny_talwar

What data do you have in FIELD1? How is that is linked to FIELD2?

swuehl
MVP
MVP

Looks like you want Field1 to only consider the current dimension value of FIELD2.

Set analysis can't do this, it's not evaluated per dimension like.

You would probably need SUM(IF(...)) for that.

Not applicable
Author

The data is something similar to this.

 

FIELD0FIELD1FIELD4
123AB
123AC
123ZA
123BC
123BD
142AB
142BC
142XA

FIELD2 lookup table which has distinct value of FIELD1 and FIELD4

 

FIELD2
A
B
C
D
X
Z

For this data if I select FIELD2 as A I should get

 

FIELD0FIELD2EXP1EXP2
123A21
142A11


If I select two values that is A,B. I want the output to be

 

FIELD0FIELD2EXP1EXP2
123A21
142A11
123B21
142B11