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

Set a variable's initial value but allow it to be changed by user interaction

I've got a couple of apps where I want to set an initial filter value, etc but I only want it to be done once (if the user changes it I don't want to force them to go back to the default). I've been using Sheet Actions to do that but the process is cumbersome.

I set up variable vChk_DefaultDateSet to be 1 in the variable editor.


Then I have two Sheet Actions (which only work when vChk_DefaultDateSet is 1)


The first action sets the filter for PIV_DAY_DATE but it uses vChk_DefaultDateSet's value to decide whether to leave it as it is or change it the max date in the data using the logic


vDate_MaxRecEffDt is the latest date in the data

vDate_CurrentPivSel is whatever is already selected in PIV_DAY_DATE


The first action sets vChk_DefaultDateSet to zero (so that the next time the sheet action is completed it doesn't change the filter)



The solution works but I have to remember to reset vChk_DefaultDateSet to 1 every time I publish the app, if I forget to manually do that then it stops working.

I'd like to load the default value of vChk_DefaultDateSet in the load script but if I do that then the Sheet Action can't change the value.

I can't use a default bookmark to set the filter because the date I'm selecting will change day to day and the default bookmark will set to a value not the output of a calculation/variable.

Anyone got any suggestions for how I can set the default value but still allow it to be amended by a Button, Sheet Action, etc?



Labels (6)
4 Replies

I'm not quite following what it is you're trying to achieve. If the goal is to have a default value but the user can change it, it seems like the correct approach is to use a default bookmark with a dynamic selection, e.g.


Insofar as the rest of what you wrote, "I'd like to load the default value of vChk_DefaultDateSet in the load script but if I do that then the Sheet Action can't change the value." - I don't quite understand why. There's no technical limitation here that I'm aware of.


I've never managed to get =date=Max(Date) to work in a bookmark. I've tried a few times and I'm missing something.

I was also sure I'd tested not being able to change variable values I'd set in load script but I checked and you're absolutely right. Thanks for the correction.


For the bookmark, you would need to apply this formula and then hit enter (do not select the value with your mouse), then save the bookmark. If you select the value with your mouse, it'll just hard-code that value.


@UncleRiotous Creating bookmark based on Max date / today will be a bit tricky.

Step1: Click selections and search for required date field. Select any one value.

Step2: Close the selections. Unselect the value from the field.
Though field name disappears, search bar and drop down values will be there like below.



Step3: Enter the max date expression.
Wait for sometime and it shows max date and then hit Enter.
If the above expression doesn't work, try below.

Step4: Save the bookmark. Now check the bookmark details and you will see like below.


In my case, I stored max date into vMaxDate variable.