Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am very new to Qlikview so this is probably a weird question. I am working on a dashboard in which a user can enter some values in an input box and I will use these values on the background for some SAS code via a stored process.
For the most part this works fine. In the script I have something like:
variable_X:
LOAD
Rowno() AS variable_X
AUTOGENERATE
100;
Now, skipping some details, in de input box you can now enter values from 1 to 100 as integer values. For example, you can enter 10 and variable_X will appear with value 10 in the current selections box. So far so good.
However, I want the user to be able to enter values with two decimals. For example, 10.50 should be a possible value. I was able to this by changing the above code by:
variable_X:
LOAD
round(Rowno()*0.01, 0.01) AS variable_X
AUTOGENERATE
10000;
Now you can enter values from 1.00 to 100.00 with two decimal precision. Still, so far so good. But what is bugging me is that you cannot enter 10 as a value in the input box anymore. In the table variable_X "10" is defined as "10.00" and hence it is not recognized in the current selections as an allowed value. This could be confusing to the user and hence I want to solve it.
Does anyone now a good solution to this problem? Any help is much appreciated!
A failed attempt by me was to add 10 and 10.00 as two different values in the table. The code I tried was:
variable_X:
LOAD
if( RowNo()<10001, round(Rowno()*0.01, 0.01), RowNo() - 10000 ) AS variable_X
AUTOGENERATE
100100;
Unfortunately, something goes wrong with the rounding. For the rows 1 up to 10000 values like 10.00 are stored as 10.
The idea was to use the same format in your action as you've used for formatting your field.
I assume your field is formatted as integer without decimals, hence =Num(vVar,0.01)
would not be the appropriate format, but for a field formatted with two decimals.
You can also try this as search string:
='=variable_X=vVar'
which should do a numerical match disregarding the format.
If you are talking about an input box, I assume you are using a Qlik Variable to store that value and then an action to make selection in field variable_x?
Maybe just use a Num() formatting in your selections, maybe something like
=Num(vVar,0.01)
Thank you for your reply. That's exactly what I am doing! I am trying to figure out how to implement your suggested solution. Could you help me out a little bit more here?
Right now I make a table of variable_X in the script like this:
variable_X:
LOAD
Rowno() AS variable_X
AUTOGENERATE
100;
Then indeed I make a Qlik Variable vVar in an input box, then add an action to make a selection in variable_x. I do that with a variable event trigger. Right now, I did this as follows:
Field : variable_X
Search string : =$(vVar)
Now al integer values of 1 up to 100 are allowed.
I do have some questions regarding your solutions now. First of all, do you suggest I try:
Search string : =Num(vVar,0.01)
And if so, do I change something in the script? Because at the moment it doesn't seem to work for me. What am I doing wrong?
The idea was to use the same format in your action as you've used for formatting your field.
I assume your field is formatted as integer without decimals, hence =Num(vVar,0.01)
would not be the appropriate format, but for a field formatted with two decimals.
You can also try this as search string:
='=variable_X=vVar'
which should do a numerical match disregarding the format.
Hi Stefan,
Thank you for you feedback. In the end I used a slightly different solution, but I accepted your solution because it was based on yours. What I did was as follows:
variable_X:
LOAD
Round(Rowno(), 0.01) AS variable_X
AUTOGENERATE
10000;
Field : variable_X
Search string : =Round($(vVar),0.01)
This worked for me!