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

How to get the last selected field value ?

Hi,

If I have a field named "EmployeeName", and I want to select from a list box a few values from this field ,

how can i know after each selection the value i have just selected?

Say i select Adam - so I want to get the name Adam into a variable,

then I select Jim, so I would like that Jim will go into the variable, and so on... I always want to know the last value i have just selected.

Thanks,

Guy

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

I was a bit disappointed to find out Qlikview doesn't have the ability to get the last selected value...

Anyway, I succeeded doing it myself.

What i wanted is that If I choose multilply values from the "_Dynamic_Expressions:" field , I'll get the last selected value and not all the selected values.

The magic happens like this (see also the attched QVW):

=concat(  if(index('$(vLastSelectionOfDynamicExp)',subfield(getfieldselections(_Dynamic_Expressions,',',vDynamicCount),',',ValueLoop(1,vFieldDymanicCount,1)))>0

    ,NULL(),subfield(getfieldselections(_Dynamic_Expressions,',',vDynamicCount),',',ValueLoop(1,vFieldDymanicCount,1))),'')

when  vLastSelectionOfDynamicExp = Concat({$1} _Dynamic_Expressions, ',')  : that means the previous selection of _Dynamic_Expressions,

so practically the concat concatenates only values that were not in the last selection, that means the last new selected value ...

I know its hard to understend this code, but take a look at the file attached, it might help.

Yours,

Guy

View solution in original post

5 Replies
settu_periasamy
Master III
Master III

Have you tried with      =GetFieldSelections([Employee Name])

You can assign this into your variable. Or if you will select always one value in the Employee Name ListBox, you can set 'Always One Selected Value'.

Anonymous
Not applicable
Author

take the text box

=GetFieldSelections([Employee Name])

Anonymous
Not applicable
Author

previous([Employee Name])

jonathandienst
Partner - Champion III
Partner - Champion III

Using the set analysis identifiers, $ = current selection, $1 = previous selection

Concat({$} EmployeeName, ',')   -- current selection

Concat({$1} EmployeeName, ',')   -- previous selection

You could display both, or you could feed this into a macro to identify the changes.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi,

I was a bit disappointed to find out Qlikview doesn't have the ability to get the last selected value...

Anyway, I succeeded doing it myself.

What i wanted is that If I choose multilply values from the "_Dynamic_Expressions:" field , I'll get the last selected value and not all the selected values.

The magic happens like this (see also the attched QVW):

=concat(  if(index('$(vLastSelectionOfDynamicExp)',subfield(getfieldselections(_Dynamic_Expressions,',',vDynamicCount),',',ValueLoop(1,vFieldDymanicCount,1)))>0

    ,NULL(),subfield(getfieldselections(_Dynamic_Expressions,',',vDynamicCount),',',ValueLoop(1,vFieldDymanicCount,1))),'')

when  vLastSelectionOfDynamicExp = Concat({$1} _Dynamic_Expressions, ',')  : that means the previous selection of _Dynamic_Expressions,

so practically the concat concatenates only values that were not in the last selection, that means the last new selected value ...

I know its hard to understend this code, but take a look at the file attached, it might help.

Yours,

Guy