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

Toggle Ascending/Descending in sort order dynamically

Hello,

I've got a variable vToggleSortOrder that has the default value of 0. By pressing a button it changes to 1 if 0 and back to 0 if 1. I've got an expression that dynamically changes the sort order depending on the variable. However, I would need to to have it be Ascending in one scenario and Descending in the other, is this possible? Or do I somehow have to manipulate the results.

Sorting is either in starting time HH:MM:SS or interval in time between two dates HH:MM:SS.

1 Reply
Not applicable
Author

Solved it by incapsuling my expression in a rank() function and it works

=if(vToggleSortOrder=1, Rank(Interval(Max({<[Date] = {'$(=DATE($(varDateSelect)))'}, [LAST_RUN_ORDER] = {'= Min({$<Date = {"=$(=Date($(varDateSelect)))"}>} LAST_RUN_ORDER)'}>} Time([ACC_END]))-Min({<[Date] = {'$(=DATE($(varDateSelect)))'}, [LAST_RUN_ORDER] = {'= Min({$<Date = {"=$(=Date($(varDateSelect)))"}>} LAST_RUN_ORDER)'}>} Time([ACC_START])))),Min({$<[Date] = {'$(=DATE($(varMaxDate)))'}, [LAST_RUN_ORDER] = {"1"}>}Time([ACC_START])))