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

Custom Sort according to selected dimension values

Hi all,

I've had this requirement/question pop up a number of times in the past couples of weeks with a client.

For example:

Say we have a Customer listbox and a table.

The user would like to show the Customers in the exact or that has been selected.

Say Customer F is selected (holding down shift), then B and then E.

The table/chart should show it in this order.

But instead it just shows the default order.

order.png

Is there any function or trick to achieve this custom order within a table.

Any ideas would be appreciated.

Thank you

1 Reply
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

There is no easy way to do this. The model and the GetCurrentSelections() function return a list of selections, in the load order of the values and there is no way to change that.

These things are rarely impossible, but sometimes not worth the effort. This is what you would have to do:

You would have to write a VBScript Macro triggered by an OnSelect and an OnChange trigger for each field that must show this behaviour. The macro would have to work out what had been added/removed from the selections each time it runs and would have to update a set of sort order variables, one per field. The variables would contain an ordered list of selected values and the sort criteria in the (straight) table would be an expression using this variable.

You will need to find an API call (if it exists) that can switch the sort order of the table based on the last selection, otherwise the sort order will depend on the interactive sort order and will confuse the user. Or turn off interactive sorting.

Good luck

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein