Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Set field from variable

I want to save the selections in a field upon entering sheet1.  Then I want to manually change the selections in that field.  Then upon leaving sheet1 I want to restore the original selections that I saved.

I tried this by GetFieldSelections and storing the result in a variable.  These are years by the way.  This results in a comma separated list.  Then I change the years to what is appropriate for Sheet1.  Then when I leave sheet1 I want to put the original list of years that I saved back into the field.  I tried doing this by taking the comma separated list, adding leading and trailing parentheses and replaced the commas with pipes.

This doesn't work.  Does anyone have any suggestions?  Maybe a better way to be able to restore the values?

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Set field from variable

Hi Ivan,

It partially works.  Once the variable starts displaying things like "All" or "Not A" it no longer works.  I added a few rows to your example to test this out.  Is there a way to fix this?  By the way, the difference between your suggestion and what I did originally was I used "$" in front of the variable name to expand it, which didn't work.  Once I saw that you didn't have a "$" in your example, I took it out and it worked, up until the variable displayed things like Not A.

12 Replies

Re: Set field from variable

Create a bookmark per sheet and use the OnLeave and OnActivate sheet triggers to save (replace) the bookmark when leaving the sheet and activating the bookmark when entering the sheet.


talk is cheap, supply exceeds demand
iktrayanov
Contributor III

Re: Set field from variable

So this (2010|2011|2012) does not work

Try to make your search string like this (*2010*|*2011*|*2012*)

Not applicable

Re: Set field from variable

Thanks that works.  I'm also going to try Ivan's solution to see if that will let me restore only certain fields.

Highlighted
Not applicable

Re: Set field from variable

Ivan,  my search string was as you supposed.  I changed it as you suggested, but it didn't work.  When I go back to another sheet all years are de-selected.

iktrayanov
Contributor III

Re: Re: Set field from variable

You may want to double check how you set your actions. It should work.

See the attached example. I created a button SetVariable that holds your selections and after changing selections another button Select that selects your saved selections. Take a look at the actions.

Not applicable

Re: Set field from variable

Hi Ivan,

It partially works.  Once the variable starts displaying things like "All" or "Not A" it no longer works.  I added a few rows to your example to test this out.  Is there a way to fix this?  By the way, the difference between your suggestion and what I did originally was I used "$" in front of the variable name to expand it, which didn't work.  Once I saw that you didn't have a "$" in your example, I took it out and it worked, up until the variable displayed things like Not A.

iktrayanov
Contributor III

Re: Set field from variable

Can you attach your example?

Not applicable

Re: Re: Set field from variable

This is your example with a few more rows.  If I select say, all rows except A, set the variable, then make a different selection and then click Select, it doesn't use the variable.

iktrayanov
Contributor III

Re: Re: Set field from variable

Sorry I know what the problem is.

I was trying something else and I forgot to remove the triggers. Go on the document properties and remove the triggers from Prod1 also go on the Select button and change the field from Prod1 to Prod2.

Community Browser