Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
Action | Variable | Value | |
---|---|---|---|
1 | Set Variable | vReportDateM1 | =Date($(vReportDate))-1 |
2 | Set Variable | vReportDateP1 | =Date($(vReportDate))+1 |
Action | Field | Search String | |
3 | Select In Field | StartDate | = '(' & Date($(vReportDateM1)) & '|' & Date($(vReportDate)) &')' |
4 | Select In Field | EndDate | = '(' & 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
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.
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.
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.
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.
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?
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.
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.