Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to sort by expression?

Hi!

Im sorry for duplicating post, there are many same posts, but I can't understand "How it work".

What I have:

  • I have one Bar Chart
  • In dimension - one variable, it can take few values by clicking on buttons (real dimensions name like region, user, month for each button)
  • In expression - two simple exp. (sum, count, it really doesn't matter)

My problem:

I want to sort month by default, but all other dimension by Y-value. (dimension can change on button click)

Please help me to understand how to do it.

Oh, please don't attach example, I can't open it (Personal Edition)

If you help me, I'll be very grateful.

Regards,

Igor

1 Solution

Accepted Solutions
Not applicable
Author

Cool idea, Deepak!

I use it, but it can be a more simply, like this :


=if(variable = month, variable, sum(Sales))


It do the same, without inline : )


Thank to all for response! And thank Deepak for good idea.

View solution in original post

6 Replies
Not applicable
Author

For the dimension, can you just not 'sort by expression' which is the same expression that you use in 'expressions'?

Regards,

Gordon

Not applicable
Author

Normal 0 false false false RU X-NONE X-NONE MicrosoftInternetExplorer4

Thank you for answer, maybe I don't understand you, or you don't understand my trouble. (English is not my native languageJ )

I don't sort by expression, I don't know how to do it.

When i sort by default, and variable in dimensions (vDimension for example) equal 'Month', then all fine, It sort Jan, Feb, Mar and so on, BUT when vDimension equal 'User' I need to sort it by Y-value.

When I sort by Y-value, all dimensions ok, BUT when dimension equal month it show "Apr,Jan, Mar…" and I need "Jan, Feb, Mar…"

How change sorting type by changing vDimension value?

Not applicable
Author

HI,

I think this is not possible. You can select one order for one dimension. If you change your dimension using a variable the (chart-)order won't change because it is bound to the dimension of the chart. You can allways use default OR Y-Axis.

A raw Idea is: change in settings --> document properties --> sort the default sorting for your dimensions as in the chart. BUT then it is the default sort for all charts.

Not applicable
Author

Thank for answer.

Normal 0 false false false RU X-NONE X-NONE MicrosoftInternetExplorer4

I think must be solution, maybe exist some method or property like Object.SortBy = 'default' and Object.SortBy = 'Y-value' or something like this. I hope it is, and not just in my dream.) Maybe exist another solution, that will have same result…

deepakk
Partner - Specialist III
Partner - Specialist III

A little tricky method.

In Srcipt level create inline with Month as field and Soryno as another field

The data should look like ( I am assuming that your MOnth starts from Jan)

Month Sortno

Jan 12

Feb 11

Mar 10

and so on

and the write the below expression in Sort by Expression

=if(variable =Month,Sortno,Sum(Sales))

in the above expression we are checking if the variable is month if yes then give then Sortno field

or else the Y Value expression..

Make sure it is in Descending Order

if you want it in Ascending make Jan = 1 and Feb = 2

I hope this helps you out..

Not applicable
Author

Cool idea, Deepak!

I use it, but it can be a more simply, like this :


=if(variable = month, variable, sum(Sales))


It do the same, without inline : )


Thank to all for response! And thank Deepak for good idea.