Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
bhaveshp90
Creator III
Creator III

How to sort the dimension in the bar chart?

Hello,

I have a bar chart with GP_Bucket as dimension and Count, Sales as expressions as shown below;

1.PNG

I want to sort the dimension in the following order > '<10%','10-14%','14-20%','20-25%', '25-30%', '30-35%', '35-40%', '>40%'

I tried to use the sort -> expression as

match(GP_Bucket,'<10%','10-14%','14-20%','20-25%', '25-30%', '30-35%', '35-40%', '>40%')

which didn't sort as per the order as shown in the image above.

I even tried using in the back end script as (Sort -> expression -> GM_Bucket_Sort)

if(GP_Bucket = '<10%', 1,

if(GP_Bucket= '10-14%',2,

if(GP_Bucket = '14-20%',3,

if(GP_Bucket = '20-25%',4,

if(GP_Bucket = '25-30%',5,

if(GP_Bucket = '30-35%',6,

if(GP_Bucket = '35-40%',7,

if(GP_Bucket = '>40%',8)))))))) as GM_Bucket_Sort,


Is there any other way to sort the dimension, or am I doing wrong here? any help is appreciated.

thanks

Bhavesh

1 Solution

Accepted Solutions
niclaz79
Partner - Creator III
Partner - Creator III

Hi,

You GM_Bucket_Sort should work. I would set the expression:

Max({1}GM_Bucket_Sort) myself.

Make sure that the sort expression is the first ranked one and there are no other check boxes clicked on.

View solution in original post

7 Replies
kingsleyh
Partner - Contributor II
Partner - Contributor II

Hi Bhavesh.

Are you able to supply us with a qvw?

Gysbert_Wassenaar

How is the field GP_Bucket created in the script? Or is it a calculated dimension?


talk is cheap, supply exceeds demand
sudeepkm
Specialist III
Specialist III

create an inline load like below just before the Load script where you have the field GP_Bucket.

GP_BucketSort:

Load * inline [

GP_Bucket

<10%

10-14%

14-20%

20-25%

25-30%30-35%

35-40%

>40%];

Reload the app and then in your Bar Chart Properties > Sort > Select Dimension GP_Bucket and then select sort by

Load Order > Original

niclaz79
Partner - Creator III
Partner - Creator III

Hi,

You GM_Bucket_Sort should work. I would set the expression:

Max({1}GM_Bucket_Sort) myself.

Make sure that the sort expression is the first ranked one and there are no other check boxes clicked on.

achettipalli
Creator
Creator

Post your workbook if you still didn't get the desired result.

bhaveshp90
Creator III
Creator III
Author

This is how I created in the scipt ;

if(GM_As_Sold <= 10, '<10%',

if(GM_As_Sold > 10 and GM_As_Sold <= 14 ,'10-14%',

if(GM_As_Sold > 14 and GM_As_Sold <= 20, '14-20%',

if(GM_As_Sold > 20 and GM_As_Sold <= 25, '20-25%',

if(GM_As_Sold > 25 and GM_As_Sold <= 30, '25-30%',

if(GM_As_Sold > 30 and GM_As_Sold <= 35, '30-35%',

if(GM_As_Sold > 35 and GM_As_Sold <= 40, '35-40%',

if(GM_As_Sold > 40, '>40%')))))))) as GM_Bucket,

bhaveshp90
Creator III
Creator III
Author

thank you Niclas, it worked like a charm