Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

QlikSense - Use getselection in expression

Is it possible to add an expression like this;

(Sum({$<Filter={'NONE SEN'}>}[vY8-Pu2])-Sum({$<Filter={'SEN'}>}[vY8-Pu2]))/Count(distinct Key)

Replace the words in red to point at a selection in a filter pane.

Any help appreciated.

Thanks

Chris

 

Labels (1)
11 Replies
sunny_talwar

In filter field or another field?

Anonymous
Not applicable
Author

In Filter Field

sunny_talwar

So if you want them to be not static and based on selection, why even have set analysis? not sure I understand what your end goal is

Anonymous
Not applicable
Author

To be able to change an expression calculation based on a selection.

This stops having to duplicate expressions and altering them by using what I think might work getselection.

sunny_talwar

Yet again I am not clear what you want,

but this,

Sum({$<Filter={'NONE SEN'}>}[vY8-Pu2])

won't change on selections.

but this will

Sum([vY8-Pu2])

Now I am not sure why you need GetFieldSelection here? Unless there is something I need to know, I think the 2nd expression above should work

girirajsinh
Creator III
Creator III

Hi Chris,

I try to guess what you are looking for.

Please give a try with following expression and see , is that something you are looking for ? I meant check if that gives your desired result ?

Sum({1-$}[vY8-Pu2])/Count(distinct Key)

That will simply Sum ( All Non selected) - Sum( all selected based on Filter pane ) / count ( distinct key)

Anonymous
Not applicable
Author

Hi,

I think I have got my self confused.

Basically I am looking at replacing field names with selections in an expression

For example (Sum(GetFieldSelections(PU,',',1))-Sum([Y8-Pu2]))/Count(distinct Key)

What I am not clear on is can I specify which selection to use in the field. For example can I use the first 2 selections from the same field, one for the first part of the expression and the second in the same expression.

Hope this makes a bit more sense.

Thanks for the help.

Chris

vinieme12
Champion III
Champion III

Store your selections in variables and use variables in set analysis

You can store the values, but NOT in the order they were selected; so you cannot make out which was selected first; leave out first two!

So your best bet is to create two list boxes for both filters.

vFilter1 = GetfieldSelections(YourField1);

vFilter2 = GetfieldSelections(YourField2);

(Sum({$<Filter={"$(vFilter1)"}>}[vY8-Pu2])-Sum({$<Filter={"$(vFilter2)"}>}[vY8-Pu2]))/Count(distinct Key)

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

in case you want to separate two selected value from one field

you may try

SubField(GetFieldSelections(Field),',',1).

&

SubField(GetFieldSelections(Field),',',2).

with assumptions that,

1. Field contails only 2 values Or will max two values can be selected.

2. Order of values selecte is not taken in to account . You can see that yourself that getfieldselections would return in one sort order.