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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
lawrenceiow
Creator II
Creator II

Set Variable and Select in Field Actions

Set Variable does not take effect until all actions completed. Is this expected behaviour?

Whilst developing I have three text objects which show the three variables vReportDateM1, vReportDate and vReportDateP1

I have a calendar object which linked to vReportDate

And I have a button with four actions:

ActionVariableValue
1Set VariablevReportDateM1=Date($(vReportDate))-1
2Set VariablevReportDateP1=Date($(vReportDate))+1
ActionFieldSearch String
3Select In FieldStartDate= '(' & Date($(vReportDateM1)) & '|' & Date($(vReportDate)) &')'
4Select In FieldEndDate= '(' & Date($(vReportDate)) & '|' & Date($(vReportDateP1)) &')'

The user should use the calendar object to select a desired date and then click the button to apply the filters.

What happens is the three text objects show the updated variables but the Current Selections box shows that the vReportDateM1 and vReportDateP1 still hold their previous value. Clicking the button a second time then the Current Selections box shows the newly updated variables.

This suggests to me that as actions 3 and 4 are being applied the change of the variable specified during actions 1 and 2 have not taken place until after all actions have completed.

Is this expected behaviour (I hope not) or is this because I am on an old version (- QlikView 11.20.12904.0 SR12)?

Regards

1 Solution

Accepted Solutions
lawrenceiow
Creator II
Creator II
Author

It was my fault for following bad practice as my variables vReportDateP1 and vReportDateM1 were simply dates, if I'd set them up as expressions then I could see how they would update when the calendar object changed vReportDate.

In actual fact I didn't need to have those two extra variables at all, I should have simply done the calculation directly in the Search String:

= '(' & Date($(vReportDate)-1) & '|' & Date($(vReportDate)) &')'

= '(' & Date($(vReportDate)) & '|' & Date($(vReportDate)+1) &')'

I just wish I had thought of that on Thursday when I had the problem. instead of as I drove in to work on Friday morning.

View solution in original post

6 Replies
m_woolf
Master II
Master II

Yes, this is expected behavior. Multiple actions are multi-threaded. The second action does not wait for the first to finish.

You can use macros, if that is an acceptable solution.

Anonymous
Not applicable

Do you have a sample app?

You shouldn't have to have the set variable action in your button press.  The variables should get updated automatically when the user uses the calendar object.

The button should only have the Select in Field action.

lawrenceiow
Creator II
Creator II
Author

Thank you for your reply atkinsow‌, I am setting three variables and, as far as I know, the calendar object will only set one variable.

lawrenceiow
Creator II
Creator II
Author

Thank you for your reply mwoolf‌ -  multi-threaded! I hadn't considered that, are you sure about that as that would then mean the order of the actions are not significant? What is the purpose of the Promote and Demote buttons if it is multi-threaded? I guess a newer version of QlikView could be multi-threaded?

Anonymous
Not applicable

Your other variables are referencing the calendar variable.  So when the calendar variable gets updated, the other variables should auto update as well.    You shouldn't need to declare the variables in the button actions.

Do you have an app to share?

See is this helps.

The use of variables to filter a date range

lawrenceiow
Creator II
Creator II
Author

It was my fault for following bad practice as my variables vReportDateP1 and vReportDateM1 were simply dates, if I'd set them up as expressions then I could see how they would update when the calendar object changed vReportDate.

In actual fact I didn't need to have those two extra variables at all, I should have simply done the calculation directly in the Search String:

= '(' & Date($(vReportDate)-1) & '|' & Date($(vReportDate)) &')'

= '(' & Date($(vReportDate)) & '|' & Date($(vReportDate)+1) &')'

I just wish I had thought of that on Thursday when I had the problem. instead of as I drove in to work on Friday morning.