Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
PhilipMertin
Partner - Contributor III
Partner - Contributor III

Sort dynamic values from valueloop - variable input in Qlik Sense

I'm creating Variable Input objects for four variables in Qlik Sense, i.e. Start Year, Start Period, End Year, End Period.

I want to dynamically adjust available values for selection for the End Period, based on selections for the others.

The expression I'm using for End Period is as follows:

=if ( $(Start_Year) = $(End_Year), 

Concat( ValueLoop( $(Start_Period), 12, 1 ) , '|' )         //Starting from selected Start Period up to 12

,

'1|2|3|4|5|6|7|8|9|10|11|12')                                 //Otherwise full list

x---------------snip--------------x

The problem is, the concat of the valueloop results are not sorted, so the user see a result which is sorted in alpha-numerical order, i.e. 10, 11, 12, 6, 7, 8, 9 (in the drop down list - if selected Start Period of 6 was chosen).

How can I sort the results? The custom object / extension in Qlik Sense doesn't have this functionality either.

Labels (1)
1 Solution

Accepted Solutions
Digvijay_Singh

Even I am surprised that this worked 🙂

Concat( ValueLoop( $(Start_Period), 12, 1) , '|',Num(ValueLoop( $(Start_Period), 12, 1)))

The third parameter is a sort_weight, but since there is no dimension field involved here, I was wondering how it will work, but the above seems to be working for me.

View solution in original post

2 Replies
Digvijay_Singh

Even I am surprised that this worked 🙂

Concat( ValueLoop( $(Start_Period), 12, 1) , '|',Num(ValueLoop( $(Start_Period), 12, 1)))

The third parameter is a sort_weight, but since there is no dimension field involved here, I was wondering how it will work, but the above seems to be working for me.

PhilipMertin
Partner - Contributor III
Partner - Contributor III
Author

I didn't know Concat had a sort_weight parameter. That's great!

Note: You don't need to do the Num for it, as the ValueLoop already returns numbers. (The concat creates the text results because of the text delimiter.)

Thanks for the quick response and help!