Sorting to your Pivot table row labels in custom order [quick tip]

Share

Facebook
Twitter
LinkedIn

Pivot tables are lovely. But sometimes they are hard to work with. Let’s say you are analyzing some HR data and want to see number of weeks worked in each hour classification. You have data like this:

raw-data-pivot-table-row-label-custom-sort

And you want this.

pivot-table-row-label-order-incorrect

Except, there is a teeny tiny problem.

The sort order on the classification is all messed up.

Here is a quick fix to get custom sort order on your pivot table row labels.

OK, I lied, There are actually two ways to do this.

The easier, but manual method:

Drag and drop the row labels to re-arrange them. Pivot table will remember this order even when you refresh. Of course there is a downside. In case you add some new values in the row label area, they will be at the bottom.

rearrange-pivot-row-labels-v1

The smarter, but slightly longer method:

pivot-table-row-label-custom-sort

  1. First define the sort order in a list. Let’s say this list is in $I$3:$I$12
  2. Now, add an extra column to the original data.
  3. Using MATCH formula, find the order of each row label (in our case, classification) in the sort order list. Assuming classification is in D3, use =MATCH(D3, $I$3:$I$12, 0)
  4. Create a pivot table with data set including sort order column.
  5. Add sort order column along with classification to the pivot table row labels area.
  6. Add the usual stuff to values area.
  7. Set up pivot table in tabular layout.
  8. Remove sub totals
  9. Finally hide the column containing sort order.
  10. Your new pivot report is ready.

Good news for people with Excel 2013 or above:

  • Once you have the sort orders table, just link to your original data set thru data model.
  • You can then use sort order column in the pivot report directly. No need to write MATCH() formula.
  • Refer to our relationship advice for Excel 2013 or above users.

Download Example Workbook

If all of this instruction is sort of tricky for you to follow, click here to download the example workbook.

How do you deal with pivot table sorting problems?

If my data is in Power Pivot, I rely on the excellent sort by feature. It is a god send. But when my data is in Excel (or I can’t use Power Pivot), I rely on the approach outlined in this post.

What about you? How do you deal with messed up sort order problems in your pivot tables? Please share your tips in the comments.

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

3 Responses to “How-to create an elegant, fun & useful Excel Tracker – Step by Step Tutorial”

  1. Malani says:

    Hi Chandoo,
    I am responsible for tracking when church reports are submitted on time or not and the variations from the due date for submission.
    Here is the Scenario;
    The due date for the submission of monthly reports is on the 5th of each month. and I would like to know how many reports have been submitted on time (i.e, those that have been submitted on or before the due date) I would also want to track those reports that have been submitted after the due date has passed.
    How can I create such a tracker?

  2. Carl says:

    Hi Chandoo,
    I am a member of your excel school.
    I was trying to create SOP Tracker I follow all your steps but I keep this error below.

    The list source must be a delimited list, or a reference to a single row or cell.

    I try looking on YouTube for answer but no luck.

    can you help on this?

    thanks
    Carl.

  3. Rakesh says:

    Dear Mr. Chando,

    Rakesh, I'm working in a private company in the UAE. Recently, I'm struggling to get more details about the staff sick, annual, unpaid, and leaves. I would like to get a tracker in excel. Could you please help me in this situation?

    I also watching your videos in YouTube. i hope you can help me on this situation.

Leave a Reply