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: 
arodriguez_nyn
Contributor II
Contributor II

Bar chart sorting by expression

Hi Community!

I am currently stuck with an issue that does not suppose to be so difficult.

I want to sort dimensions in a bar chart by an expression and did several trials. You can see my  bar chart in the image I uploaded. There I want the Hotel dimension to be sorted like this:

Match(Hotel,'B Hotel', 'Barcelona Universal', 'Hotel 1898', 'Hotel Europark', 'Hotel Gran Vía', 'Hotel Jazz', 'Hotel Paral.lel', 'Hotel REC Barcelona', 'Hotel SOHO Barcelona', 'Hotel The Corner', 'Midtown Apartments', 'U232 Hotel')

I set this formula in the custom expression field and did not work. It only sorted the legend.

My second trial was, following this video Changing the sorting of a visualization using expressions - Qlik Sense,  doing a much more elaborated formula:

If(Hotel = 'B Hotel',1,
If(Hotel = 'Barcelona Universal', 2,
If(Hotel = 'Hotel 1898', 3,
If(Hotel = 'Hotel Europark', 4,
If(Hotel = 'Hotel Gran Vía', 5,
If(Hotel = 'Hotel Jazz', 6,
If(Hotel = 'Hotel Paral.lel', 7,
If(Hotel = 'Hotel REC Barcelona', 8,
If(Hotel = 'Hotel SOHO Barcelona', 9,
If(Hotel = 'Hotel The Corner', 10,
If(Hotel = 'Midtown Apartments', 11,
If(Hotel = 'U232 Hotel', 12))))))))))))

It did´nt work either. My next step was to try an Inline table to do the job:

OrdenHoteles:
Load * Inline [
Hotel, OrdenHotel
B Hotel, 1
Barcelona Universal, 2
Hotel 1898, 3
Hotel Europark, 4
Hotel Gran Vía, 5
Hotel Jazz, 6
Hotel Paral.lel, 7
Hotel REC Barcelona, 8
Hotel SOHO Barcelona, 9
Hotel The Corner, 10
Midtown Apartments, 11
U232 Hotel, 12
];

Then I set the dimension OrdenHotel  in the custom expression field, but Qlik Sense seemed to ignore it.

Finally I mapped the field Order to the Hotel tables and try to use it with the same result:

OrdenHoteles:
Mapping
Load * Inline [
Hotel, OrdenHotel
B Hotel, 1
Barcelona Universal, 2
Hotel 1898, 3
Hotel Europark, 4
Hotel Gran Vía, 5
Hotel Jazz, 6
Hotel Paral.lel, 7
Hotel REC Barcelona, 8
Hotel SOHO Barcelona, 9
Hotel The Corner, 10
Midtown Apartments, 11
U232 Hotel, 12
];

IristraceCheckList:
Load
*,
ApplyMap('OrdenHoteles',Hotel) as Orden
Resident tmpIristraceCheckList;

Certainly I am not an expert in Qlik Sense, so it´s very likely that I omitted something.

Any help would be greatly grateful!

Kind Regards!

 

 

 

1 Solution

Accepted Solutions
sunny_talwar

Use this expression

Match(Only({1} Hotel),
'B Hotel',
'Barcelona Universal',
'Hotel 1898',
'Hotel Europark',
'Hotel Gran Vía',
'Hotel Jazz',
'Hotel Paral.lel',
'Hotel REC Barcelona',
'Hotel SOHO Barcelona',
'Hotel The Corner',
'Midtown Apartments',
'U232 Hotel')

And move the sorting for Hotel above NumberOfChecklists under Sorting

image.png

View solution in original post

4 Replies
sunny_talwar

I am not seeing any image, did you forget to attach one? Also, it might be easy if you are able to share a sample qvf to see the issue

arodriguez_nyn
Contributor II
Contributor II
Author

Hi Sunny:

Please find attached a very basic qvf file where I am still not able to customize the sort order 😞

Thanks in advance!

sunny_talwar

Use this expression

Match(Only({1} Hotel),
'B Hotel',
'Barcelona Universal',
'Hotel 1898',
'Hotel Europark',
'Hotel Gran Vía',
'Hotel Jazz',
'Hotel Paral.lel',
'Hotel REC Barcelona',
'Hotel SOHO Barcelona',
'Hotel The Corner',
'Midtown Apartments',
'U232 Hotel')

And move the sorting for Hotel above NumberOfChecklists under Sorting

image.png

arodriguez_nyn
Contributor II
Contributor II
Author

Thanks Sunny! Moving the Hotel sorting was the key!