Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
mcsmithums
Contributor II
Contributor II

Parameters for Variables

Hello,

 

I have started working in QlikSense and am currently developing an app. I am using a variable vTotal, that is set to be the sum of 6 other variables. I am wondering if there is a way to make vTotal have a maximum amount. My other variables are sliders that go from 0-100 and I would like vTotal to have a maximum of 100 as well. Let me know, thank you.

Labels (2)
1 Solution

Accepted Solutions
henrikalmen
Specialist
Specialist

Not really. What you could do, if it's approporiate for what you are doing, is to have two variables for each actual variable you want to use - one input and one that get's used.

You have for example one variable "var2input" that the user can set to a value. You can't put a conditional constraint on it, so the user could enter e.g. 110.

But when you are going to use the value that the user has entered, you could do that through another variable with conditions. For example var2 could be =if($(var1)+$(var2input)>100, 'ERROR', $(var2input)) so that you could show an error message elsewhere to try to force the user to change the input. 

But in your situation I believe it will be a really ugly workaround, especially with so many different variables that you want to use.

You could also use the footer or tite fields in the variable input object to show error text if a value is entered that you don't approve of.

None of these suggestions are what you actually want but those are the ideas I come to think of.

 

View solution in original post

6 Replies
henrikalmen
Specialist
Specialist

Something like this in vTotal should result in 100 or less, in this example based on the sum of two other variables.

=if( $(var1)+$(var2)>100, 100, $(var1)+$(var2))

mcsmithums
Contributor II
Contributor II
Author

This totally makes sense and can work. Adding on, say variable 1 has been set to 100, and you try to set variable 2 to 10 is it possible to have that be an error and not be able to be set to that amount? Only inputs that succeed are ones valid by a certain constraint? I know this is slightly pushing a visualization tool, but constraint and parameters would be extremely helpful for the project I am working on. Thanks!

henrikalmen
Specialist
Specialist

Not really. What you could do, if it's approporiate for what you are doing, is to have two variables for each actual variable you want to use - one input and one that get's used.

You have for example one variable "var2input" that the user can set to a value. You can't put a conditional constraint on it, so the user could enter e.g. 110.

But when you are going to use the value that the user has entered, you could do that through another variable with conditions. For example var2 could be =if($(var1)+$(var2input)>100, 'ERROR', $(var2input)) so that you could show an error message elsewhere to try to force the user to change the input. 

But in your situation I believe it will be a really ugly workaround, especially with so many different variables that you want to use.

You could also use the footer or tite fields in the variable input object to show error text if a value is entered that you don't approve of.

None of these suggestions are what you actually want but those are the ideas I come to think of.

 

mcsmithums
Contributor II
Contributor II
Author

I agree, because there are 6 variables, it would get very clunky doing that. Unfortunate you cannot do constraints but, oh well. Thank you for the ideas! I might implement the error text just to remind someone who may not count correctly, but besides that not sure what can be done.

marcus_sommer

The nested if-loop might be shortened by nesting range-functions, maybe something like:

rangemin(100, rangemax($(var1), $(var1) + $(var2), $(var1) + $(var2) + $(var3), ...))

Beside you may consider not to limit vTotal else the slider itself by defining the max-values, maybe like:

100 - $(var1) - $(var2) - $(var3) ...

muhammedraleen
Partner - Creator
Partner - Creator

Hi @mcsmithumsmcsmithums,

Please check the attached QVF file, where it is handled with 3 variables. Please check whether it meets your requirement.