Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Try this as numeric sorting expression: if(Country='Germany', 0, ord(left(Country,1)))
There are 2 easy ways to to this:
Both work:
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:
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:
If(Match(Country, 'Germany', '...'), 0, 1)
I used '...' as a placeholder for other countries that you might want to have at the top.
Just the below would suffice
Choose Sort by Expression
Sort Descending
Expression=wildmatch(Country,'Germany')
True, that should be enough. You don't even need to use wildmatch:
=match(Country, 'Germany')
Try this at script level
IF(match(Country, dual('Germany',1)), Country) as Country
Try this
Dual(1 & '|Germany', 'Germany')
Dual(2 & '|Austria', 'Austria')
Dual(2 & '|Belgium', 'Belgium')
...
@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.
True sorry my bad 😔
How is our BOT doing?