Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to store values of previously selected fields in a variable

Hi Qlik viewers,

I wanted to store the previously selected values of a field into a variable.

The scenario is like:

There is a list box with values A,B and C and Update button passing the selected value to the variable using getfieldselections.

When A is selected and update button is clicked. The variable will have A.

Next B is selected and update button is clicked the variable should contain A,B.

Is there a way out to retrieve previously selected value of a list box/multibox.

Thanks and regards,

Pratik

16 Replies
vincent_ardiet
Specialist
Specialist

And if you want to let your users pick multiple values and also not do destroy the string when the clear button is pressed, change the following expressions:

First trigger on FieldA to assign vconcat:

='$(vconcat)'&if(GetSelectedCount(FieldA)>0,if(len('$(vconcat)'),',','')&concat(distinct FieldA,','))

Second trigger on FieldA to assign vconcatSA:

='$(vconcatSA)'&if(GetSelectedCount(FieldA)>0,if(len('$(vconcatSA)'),',','')&'|'&concat(distinct FieldA,'|,|')&'|')

Regards,

Vincent

Not applicable
Author

Hi Vincent thanks for your reply again.

But its not giving me the desired results.

When nothing is selected vconcat is blank and vconcatSA is blank, then when i select 1 from FieldA, vconcat has 1,1 and vconcatSA has |1|,|1| and so on..

And upon using the aggr expresion in list box expression it gives blank. No values are populated in the list box.

Can u post the qvw in which you got the results, maybe I am missing some steps.

Regards,

Pratik

vincent_ardiet
Specialist
Specialist

Here it is.

Not applicable
Author

Hi Vincent you qvw is the exact solution which I am looking for. Thanks alot.

The list box expression is working now, idk why but earlier it gave an error in expression. I copied yours and changed the field values this the list box popped up with values.

But I am unable to see your variable expressions. for cumul and cumul2.

Can you please paste them here.

Thanks,

Pratik

Not applicable
Author

vincent_ardiet
Specialist
Specialist

Pratik,

cumul and cumul2 are just used to store the result.

The trigger actions on field col3 are using expressions to build them (see document properties/triggers/field event triggers).

Not applicable
Author

Thanks Alot Vincent!