Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
er_abhichandra
Contributor III
Contributor III

Sorting in a bar chart

Hi,

I have a bar chart with two dimensions, Year and ProductType. I am displaying the current YearQtr plus last 4 YearQtrs, based on selections.

I am trying to sort the Product types in a particular order through expression in Sort tab.


The problem I am facing is that the products are getting sorted only for the Year and quarter selected in the filters. for the last 4 YearQtr it is not sorting in the same order. If i select multiple Years or Qtrs, then for those YearQtrs, the ProductTypes are getting sorted. I haven't faced this kind of behaviour before. Usually it sorts for the entire chart irrespective of selections.

Your thoughts?

Thanks,

Abhinava

18 Replies
saumyashah90
Specialist
Specialist

You can check on 3 options and let me know.

1)Check where Date format for each field defined is same(Year,Quarter also).

2)under Sort tab uncheck all and check only State.

3)If problem persist uncheck State and check in Expression,Put your date field for quarte /year and save it and check

1.png

ashishkalia
Partner - Creator
Partner - Creator

Dear Abhinav its bettr if u create id for each quarter-Year and then sort then according to this ID.

Wat u need to do is to go to the script and in ur calander tab take resedent of ur calander and generate id like

LOAD DISTINCT Quarter-Year,

                         RowNo() as Qtr-Year_ID,

RESIDENT CALANDER;

and then go to the chart and sort tab and sort according to that Qtr-Year_ID.....
I hope that may help.

er_abhichandra
Contributor III
Contributor III
Author

Hi Ashish, I am not trying to sort by YearQtr.. that is already done. I am tryin gto sort by the Product Type in a specific order.

Thanks,

Abhinava

chematos
Specialist II
Specialist II

Hi,

You can use match() function in order to sort by products.

Use something like this in the Expression combo in Sort menu:

=match (only(Product), 'Product1', 'Product2', 'Product3',  'Product4')


Regards,


Jose

Not applicable

In the expression of sort tab put your expression which you have for the product types and then select ascending.

Not applicable

Are you saying that you need stacked colours in a bar should be in the same order as you have used them in legend or whole bars should be sorted by product type's expression?

er_abhichandra
Contributor III
Contributor III
Author

The stacked colours in a bar should be of same order as in the legend.

Thanks,

Abhinava

Not applicable

Have you tried the persistent colours option under colours tab?

Not applicable

If your problem is solved, its better to close this thread by choosing the right answer or posting it.