Skip to main content
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
wdchristensen
Specialist
Specialist

Setting a Variable at Run Time in a Qlik Sense application

I have a combo chart that has a variable that checks to see if the actual is within +/- 10% of the budget and set the bars from green to red based on the result. Currently a variable is hardcoded to 10 to determine whether or not the actual is within the threshold. However, I would like to make it dynamic so the user could change the threshold to 5% or 15% as needed. I would like to add something like combo box or drop-down list box that the user can override the default value with. I am trying to accomplish this without using any extensions. Does anyone have any good ideas on how to implement this? I appreciate the help!

http://www.codewander.com/qlik-sense-color-code-combo-chart-bar-conditionally/

4 Replies
wdchristensen
Specialist
Specialist
Author

This is not great but it will "work for now".

In the load script add a data island:

Threshold:

Load * inline [

Threshold

2.5

5

10

15

20

25

];

set the variable to

=If(Len(GetFieldSelections(Threshold))>0, SubField(GetFieldSelections(Threshold), ','), 10)


I am not a huge fan of this solution since it does allow users to potentially select multiple thresholds. Ideally the selection in the filter pane should be restricted to one number only but I am not sure how to accomplish that without an extension. Unfortunately it seems like everything I read about requires an extension.

wdchristensen
Specialist
Specialist
Author

bump

marcus_sommer

What about just using min/max/avg(Threshold) or maybe alt(Threshold, AnyDefaultValueYouLike) ?


- Marcus

wdchristensen
Specialist
Specialist
Author

Marcus, I appreciate the response. Additionally, thanks for showing me the "alt" function. The "alt(Threshold, AnyDefaultValueYouLike)" is almost exactly what I had only with a different error handling (when multiple selections are made). In my original version it took the lowest numerical value and your solution reverts to the default. I think reverting to the default may a more desirable approach but I will let the business decide. Too bad you need an extension to restrict the number of selected items to one. Seems like every time I build a new app I really "need" an extension to get the desired functionality.