Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sorted concat() with added null() value

In my database I have a field called accounting_period that holds a period in format YYYYMM.

I want the user to be able to select one of the periods for use in a set analysis expression (meaning that a list box is not usefull as QV will filter on the selected accounting period as soon as the user selects a period. Therefore, I have created a variable called vPeriod1 that will hold the selected period. However, the user should be able to either select an existing period or select no period (in which case no calculation is performed (and an error message is shown on the chart indicating that a period should be selected)

So my overview should contain all distinct values of the field accounting_period AND the null value (or a blank)

I would like the result to be shown as follows :

<blank> (a blank or the null value)

all accounting periods in a descending order (starting with the highest period and descending.

I have not been able to sort the accounting period descending.

The formula I am using now resides in the listed values box in an input box with constraints set to predefined values only in drop-down

=';'&Concat({1} distinct accounting_period,';')

How can I get the periods to be shown in a descending way (201006 201005 201004 instead of 201004 201005 201006) ?

2 Replies
Not applicable
Author

Are your accounting_periods strings or numbers? Either way, you can use the sort-weight parameter in the Concat function.

For numbers:

=';'&Concat({1} distinct accounting_period,';', -accounting_period)


For strings, it is a little more work, but:

=';'&Concat({1} distinct accounting_period,';', -num#(accounting_period))


bullish35
Creator II
Creator II

This worked for me. I used the expresson for a string (vs. numbers). Wish I had the option of marking your answer, definitively, as the correct answer.