Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Jay_Vantis
Partner - Contributor
Partner - Contributor

Sort Pie Chart Legend Order by Custom Order

I have the following pie chart that I want to sort the legend order.

Jay_Vantis_0-1719998875593.png

I also have this table in my script which might help with custom sorting. I don't know how to implement it though.

[Reason Codes]:
Load * Inline [
Reason Code, Reason Code Number
Recut: Fabric Quality, 1
Remnant, 2
Spread Loss, 3
Recut: Human Mistakes, 4
Unaccount, 5
];

I tried Sort by function, and then use Pick/ Match([Reason Code]) or Pick/ Match([Reason Code Number]) but it didn't work.

Labels (5)
2 Replies
Rishabh_Chaudhary
Partner - Contributor II
Partner - Contributor II

Can you share the script for custom order you wrote in Sorting? 

Respect to the data provided by you. 

Go to sorting tab > Turn off Auto > Select sort by expression > Select Ascending order > Then add the below expression: 

Try this once, 

Pick(Match ([Reason Code], 'Recut: Fabric Quality','Remnant','Spread Loss','Recut: Human Mistakes',
'Unaccount'
)
,1,2,3,4,5
)

Jay_Vantis
Partner - Contributor
Partner - Contributor
Author

Hi, I tried your script but it only changed the order of the segments in the pie chart, but I want to change the order of the legends on the right.