• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Sort category in a specific order|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Sort category in a specific order|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QuerySort category in a specific order
sp_PrintTopic sp_TopicIcon
Sort category in a specific order
Avatar
guanyu zheng

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
September 2, 2020
sp_UserOfflineSmall Offline
1
September 2, 2020 - 9:50 am
sp_Permalink sp_Print

Hi,

In power query/pivot table, the ordering function seems sort values either alphabetically or ascendingly (descendingly). Is it possible to sort value in a specific order?

I have a census data which contains population counts across regions and types of qualification. I would like to order statistics in the following order in qualifcation.

No qualification

level 1 certificate

level 2 certificate

level 3 certificate

level 4 certificate

level 5 diploma

level 6 diploma

Bachelor and level 7 qualification

post-graduate and honours degrees

masters degree

doctorate degree 

Any helps and tips are welcome! Thanks

Cheers

Guanyu

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1510
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
September 2, 2020 - 2:18 pm
sp_Permalink sp_Print

Hi Guanyu,

You can create a custom list and sort your pivot table by that.

File -> Options -> Advanced -> Edit Custom Lists

and create a new list in the desired order.

In your pivot table options -> Totals and Filters under 'Sorting', Use custom lists when sorting should be checked.

If you want a custom sort order in Power Query you'll need to assign numeric values to the qualification types and sort by those numbers.  You can do this assignment either in your source data, or you can create a custom column within PQ.

But, if your data is going to end up in a pivot table then don't do the sorting in PQ, just use the custom lists.

If you need further assistance please supply a workbook with your data.

Thanks

Phil

Avatar
guanyu zheng

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
September 2, 2020
sp_UserOfflineSmall Offline
3
September 2, 2020 - 2:58 pm
sp_Permalink sp_Print

Hi Phil,

Thanks for your response. I believe it's easier to communicate with some data. However, I don't know how to share data in this platform. So I copy a very small subset of data here to illustrate

The first dataset contains six variables, shown below. 

area_code area_name year highest_qual counts
100100 North Cape 2006 No qualification 405
100100 North Cape 2006 Level 1 certificate 147
100100 North Cape 2006 Level 2 certificate 84
100100 North Cape 2006 Level 3 certificate 45
100100 North Cape 2006 Level 4 certificate 99
100100 North Cape 2006 Level 5 diploma 21
100100 North Cape 2006 Level 6 diploma 33
100100 North Cape 2006 Bachelor degree and Level 7 qualification 24
100100 North Cape 2006 Post-graduate and honours degrees 6
100100 North Cape 2006 Masters degree 9
100100 North Cape 2006 Doctorate degree 0
100100 North Cape 2006 Overseas secondary school qualification 18
100200 Rangaunu Harbour 2006 No qualification 519
100200 Rangaunu Harbour 2006 Level 1 certificate 234
100200 Rangaunu Harbour 2006 Level 2 certificate 123
100200 Rangaunu Harbour 2006 Level 3 certificate 93
100200 Rangaunu Harbour 2006 Level 4 certificate 117
100200 Rangaunu Harbour 2006 Level 5 diploma 27
100200 Rangaunu Harbour 2006 Level 6 diploma 63
100200 Rangaunu Harbour 2006 Bachelor degree and Level 7 qualification 51
100200 Rangaunu Harbour 2006 Post-graduate and honours degrees 12
100200 Rangaunu Harbour 2006 Masters degree 3
100200 Rangaunu Harbour 2006 Doctorate degree 0
100200 Rangaunu Harbour 2006 Overseas secondary school qualification 39

 

The second dataset contains the qualification category and order values

highest_qual order
No qualification 1
Level 1 certificate 2
Level 2 certificate 3
Level 3 certificate 4
Level 4 certificate 5
Level 5 diploma 6
Level 6 diploma 7
Bachelor degree and Level 7 qualification 8
Post-graduate and honours degrees 9
Masters degree 10
Doctorate degree 11
Overseas secondary school qualification 12

I'm able to update these two data in power pivot and to merge them together by the qualification (highest_qual) information. The thing I struggle is to find any function to tell excel to order qualification using the "order" value.

I really hope that make senses to you and helps you to understand my question.

Cheers

Guanyu

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1510
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
September 2, 2020 - 4:43 pm
sp_Permalink sp_Print sp_EditHistory

Hi Guanyu,

Use the Custom Lists as I described to sort your pivot table.

By the Way - to upload a file : Under the box where you type your replies there's a button named 'Attachments'.  Click that and then select your file(s) and then click 'Start upload'.

Instructions on the process are here

https://www.myonlinetraininghu.....this-first

Regards

Phil

Avatar
guanyu zheng

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
September 2, 2020
sp_UserOfflineSmall Offline
5
September 2, 2020 - 6:20 pm
sp_Permalink sp_Print

Thanks Phil,

That's really helpful. 

If I share the pivot table with other colleagues, is this custom list available?

Cheers,

Guanyu

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1510
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
September 3, 2020 - 2:48 pm
sp_Permalink sp_Print sp_EditHistory

Hi Guanyu,

Yes the custom list will be stored in the workbook so if it's opened elsewhere you (or someone else) can sort using that CL.

However, the CL will not be visible in the CL Dialog (File -> Options -> Advanced) on other computers.  There are some other restrictions on using a CL on a computer other than the one it was created on:

Microsoft - Custom Lists

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mark Carlson
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
yashal minahil
Oluwadamilola Ogun
Yannik H
dectator mang
Francis Drouillard
Orlando Inocente
Jovitha Clemence
Maloxat Axmatovna
Ricardo Freitas
Marko Meglic
Forum Stats:
Groups: 3
Forums: 24
Topics: 6201
Posts: 27185

 

Member Stats:
Guest Posters: 49
Members: 31861
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.