Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
BoXiangWang
Contributor II
Contributor II

Fix the first value among dimension in filter pane

Hello,

I am new to QS and there is a question I've been confused with.

Say that I've created a filter pane for Country. I want “Germany” listed first and the rest of the countries should be listed in alphabetical order.

What can I do? Is it possible to use custom sorting function to achieve this?

Thanks for any suggestions.

Labels (2)
10 Replies
henrikalmen
Specialist
Specialist

Try this as numeric sorting expression: if(Country='Germany', 0, ord(left(Country,1)))

 

LRuCelver
Partner - Creator III
Partner - Creator III

There are 2 easy ways to to this:

  1. (left) Adding a field to determine the order
  2. (right) Using an expression to determine the order

Both work:
LRuCelver_0-1707207484470.png

 

For the first option I've included a second field "PrioritySort" in the Datamodel:

Data:
NoConcatenate Load
    Country,
    Num(PrioritySort) as PrioritySort
Inline [
    Country, PrioritySort
    Angola,
    Buthan,
    Congo,
    Dominica,
    Ethiopia,
    Fiji,
    Germany, 1
    Honduras,
    India,
];

In the filterbox you can then set the field to be sorted by an expression referencing the "PrioritySort" field:

LRuCelver_1-1707207663721.png

This approach is great if the sorting order is supposed to be used several times within the app or might be changed in the future.

If you need the sorting order just a few times and don't expect to change it, you can use an expression instead:

LRuCelver_2-1707207801279.png

If(Match(Country, 'Germany', '...'), 0, 1)

I used '...' as a placeholder for other countries that you might want to have at the top.

vinieme12
Champion III
Champion III

Just the below would suffice

 

Choose Sort by Expression

Sort Descending 

Expression=wildmatch(Country,'Germany')

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
henrikalmen
Specialist
Specialist

True, that should be enough. You don't even need to use wildmatch:

=match(Country, 'Germany')

qv_testing
Specialist II
Specialist II

Try this at script level

IF(match(Country, dual('Germany',1)), Country) as Country

Chanty4u
MVP
MVP

Try this

Dual(1 & '|Germany', 'Germany')

Dual(2 & '|Austria', 'Austria')

Dual(2 & '|Belgium', 'Belgium')

 

...

henrikalmen
Specialist
Specialist

@Chanty4u I don't see the point in that. Dual() is used to assign a numeric value and a text value. but your example results in two text values and that's not what the Dual() function expects.

Chanty4u
MVP
MVP

True sorry my bad 😔

jochem_zw
Partner Ambassador
Partner Ambassador

How is our BOT doing?