Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I've noticed a strange issue:
I do have a chart that uses variables in Set Analysis.
Example:
//Variables defined in the script:
let vDR1Start = Num(MakeDate(2016,6,20));
let vDR1End = Num(MakeDate(2016,6,27));
let vDR2Start = Num(MakeDate(2016,5,20));
let vDR2End = Num(MakeDate(2016,5,28));
These variables are defining the range of dates the chart is displaying the numbers for (Start/End of Periods 1 and 2)
The Set Analysis looks like:
sum({<Date = {"=(Date<='$(vDR1End)' and Date>='$(vDR1Start)')"}>} Sales)
The chart is working properly and is updated as soon as variables are updated in the app.
I was hoping to create a single variable to use in all related charts in the application.
This new variable in the script looks like:
set vSumPeriod1 = sum({<Date = {"=(Date<=vDR1End and Date>=vDR1Start)"}>} Sales);
But if this vSumPeriod1 variable is used in chart's measure, the chart is not updated automatically as soon as variable is changed!
It requires a "refresh" - for example if ANY field is selected and cleared - the chart is immediately updated.
I am attaching the demo application to this post so the issue will be more visible.
The chart on the right is using "normal" Set Analysis, the one on the left uses variables.
To change variables, I am using an extension from the Branch (Qlik Branch)(also attached).
You can enter Dates as Numeric or Date formats, it does not matter.
I am really puzzled with this issue. Not sure if it's a bug in QS or I need to update my Expression's variable differently to handle this case.
Will appreciate an advice.
Regards,
Vladimir
"Constructed the variable using chr() and concatenations."
Sorry, that's what I meant by "escaping".
"I've submitted this case to Qlik support, will see what they will tell about this "refreshing" issue" .
I'll be curious to hear if they come back with anything other than "unsupported" on an extension issue.
-Rob
Hi,
Try to create the variable in frontend, instead of in script.
If you create variable in frontend then it works.
Regards,
Kaushik Solanki
Kaushik,
First of all, it does not work (I've tried it - see updated app in attachment). Second of all, I need to share these variables between multiple applications, so I need to have them generated in the script...
Regards,
Vlad
Vlad, It works for me if I define the variable same as the expression. That is, including the '$()' around the variable.
sum({<Date = {"=(Date<='$(vDR2End)' and Date>='$(vDR2Start)')"}>} Sales)
You will need to escape those $ if you want to set the variable in the script.
"Not sure if it's a bug in QS ..."
Keep in mind that you are using an extension, not a supported component. If it did not work, it would be hard to characterize that as a QS bug.
-Rob
Rob,
Thanks for reply.
I've tried your suggestion, but it does not work either.
The chart is updated only if the "refresh" is called (as I've mentioned in the original post, the "refresh" event is caused by selecting/clearing any field in the app, or updating chart's properties, the Title for example).
I understand your concern about updating variables by extension, but as you can see in the app (the updated QVF is attached) the variables are updated immediately and it's shown in the Text objects...
I've submitted this case to Qlik support, will see what they will tell about this "refreshing" issue..
Thanks for your suggestion.
Vlad
Rob,
I've used your suggestion and improved it a bit further. Constructed the variable using chr() and concatenations.
It works perfectly now.
Here is the variable constructed in the script:
let vSumPeriod1R_Script = 'sum({<Date = {"=(Date<=' & chr(39) & chr(36) & chr(40) & 'vDR1End' & chr(41) & chr(39) & ' and Date>=' & chr(39) & chr(36) & chr(40) & 'vDR1Start' & chr(41) & chr(39) & ')"}>} Sales)';
Thank you for your help and a suggestion!
Regards,
Vlad
"Constructed the variable using chr() and concatenations."
Sorry, that's what I meant by "escaping".
"I've submitted this case to Qlik support, will see what they will tell about this "refreshing" issue" .
I'll be curious to hear if they come back with anything other than "unsupported" on an extension issue.
-Rob
Rob,
I've read your mind than... 🙂
Will post a reply from Support if useful.
Regards,
Vlad