Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
raghavsurya
Partner
Partner

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
Partner

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.

bill_markham

Raghav


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



Best Regards,     Bill

stevedark
Luminary Alumni
Luminary Alumni

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
Luminary Alumni
Luminary Alumni

Steve,

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

-Rob

stevedark
Luminary Alumni
Luminary Alumni

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
Partner
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