Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
raghavsurya
Partner - Specialist
Partner - Specialist

dynamical change sort order


Hi All,

Can anyone suggest a way to change the sort order by click of a button.

Regards,

Raghav

10 Replies
agilos_mla
Partner - Creator III
Partner - Creator III

Hi,

You can only interfer on the sort order by putting some variables in the "sort by expression" options.

See attached sample that allows you to change priorities on the fly...

Michael

sundarakumar
Specialist II
Specialist II

create a variable and use it in sort expression.

create buttons or text boxes with trigger to set variable to what u want it to be...

Please attach a sample so that we can help u in the same.

-sundar

marchoctober
Creator
Creator

You can use expression in Sort options.

You could set this to very complex logic containing lot of ifs, so the buttons will act based upon the conditions.

Anonymous
Not applicable

Raghav


Double clicking the column header of table sorts that column, would that suffice.



Best Regards,     Bill

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Why do you want to do it from a button click - as Bill says double clicking the column head will re-sort - provided that you have a valid sort order ticked for all fields (eg. numeric or text).

If you want to use a button then you will have to use an Expression based sort.  It may be that you put the same expression as you have for the main expression into the sort expression - or you could use something else.

As you can't change the Ascending/Descending option on the sort order in code you will need to build the sort order into your expression.  If it is a numeric you could flip the order by adding your value onto a very big negative number - which is either there or not based on a variable.

To do this, create a button to flip the value of a variable (vSortFlag) between zero and one.

Make your expression something like:

(-999999999999999 * vSortFlag) + sum(Value)

Replace sum(Value) with your expression.

You will probably want to turn off Interactive Sort on the Sort tab.  You will definitely want to turn off the Sort Indicator on the Presentation tab.

If you don't know how to create the buttons check this document:

QlikView App: At The Qlik Of A Button

Hope that helps,

Steve

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Steve,

I frequently use buttons to toggle listboxes between Frequency and Alpha sort -- using the expression method.

-Rob

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Rob,

I hadn't thought of that use case.  No one has asked me to do that as yet!  Thanks for the tip.

Steve

raghavsurya
Partner - Specialist
Partner - Specialist
Author

thanks Steve

tellmalaika17
Contributor II
Contributor II

Hi Rob,

I have trouble sorting a line chart based on Frequency - Ascending. On opening the qvw the order changes from Frequency - ascending to descending. Do you have any suggestion to fix this issue??

Thanks,

Malaika