Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
michael_klix
Creator II
Creator II

dynamic sort order for expressions

Hello,

I have various measurements with a flag "high is good" and country as a dimension.

When presenting them in a bar chart, I want them to sort from "bad to good", meaning the worst are left and the better ones are to the right and potentially I have to scoll to see them.

As mentioned before, with the flag "high is good" altering, some need to be sorted ascending and some descending.

How can I make this depending on the flag?

Hope this was well explained.

Keep Qliking

Michael

1 Solution

Accepted Solutions
marcus_sommer

Hi Michael,

I have done such interactive sorting with a sort-expression like:

YourChartExpression - $(vSortDirection)

where vSortDirection contained either 0 or a very high value like 10000000000 which will be reverse the sorting. You could set the variable with a inputbox or a button and as alternatively you could also use a field-selection maybe from a small inline table like:

SortDirection:

Load * Inline [

Direction, SortValue

Ascending, 0

Descending, 1000000000

];

and your sort-expression could be:

YourChartExpression - SortValue

- Marcus

View solution in original post

11 Replies
Chanty4u
MVP
MVP

in sort tab...

Expression:

=Match(FieldName,' A','b','c')     lik so on

or u wan load order  ascending or desc  chk thatexp.PNG

Kushal_Chawda

Go to Bar chart properties-> Sort Tab-> Sort it by expression ascending or descending

or sort it by Y-Value

Not applicable

Hi Michael

U can use the Match Function, it returns a 1 if a value in the list you specify is found and 0 if the value was not found

=Match(flag, 'high is good') will return 1 for all the rows that contains 'high is good' and they will be first if you sort by expression showed in Chanty's post

sujeetsingh
Master III
Master III

You can have a number generated in the script itself to sort it.

HirisH_V7
Master
Master

Hi,

Look into this,

Sorting in qlikview

-Hirish

HirisH
“Aspire to Inspire before we Expire!”
marcus_sommer

Hi Michael,

I have done such interactive sorting with a sort-expression like:

YourChartExpression - $(vSortDirection)

where vSortDirection contained either 0 or a very high value like 10000000000 which will be reverse the sorting. You could set the variable with a inputbox or a button and as alternatively you could also use a field-selection maybe from a small inline table like:

SortDirection:

Load * Inline [

Direction, SortValue

Ascending, 0

Descending, 1000000000

];

and your sort-expression could be:

YourChartExpression - SortValue

- Marcus

michael_klix
Creator II
Creator II
Author

Hi Markus,

just the right hint, but i do it even more simple now:

The wayto revert the sorting order is to multiply the expression value with (-1).

As my flag "High is good" unfortunately is (0,1), I use the sorting Expression

= (2*flag_High_Is_Good -1)           //this is -1 for high is good=0

* MyExpression

That works perfectly. Does it make sense this way?

If someone want to add a user interaction capability to change the sorting in a chart, then a button to toggle a variable (-1,1) would be appropriate as well, of course.

Thanks a lot for all contributions.

Keep Qliking

Michael

marcus_sommer

Hi Michael,

it's a great solution - I like it.

- Marcus