A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi folks,
I had one of our engineers take a look, and it turns out that my understanding as to how this works, and how it's supposed to work were incorrect. The bad news is that Excel does not have precisely the feature we thought it had, but the good news is that there is a workaround that I think makes it possible to get the desired result with a little bit of work. Let me explain:
- Sort one column by another is a feature that works within the Power Pivot window. When you are browsing, sorting and filtering within Power Pivot, the sorting will obey any instructions you have provided to sort one column by another.
- Excel PivotTables do not have any knowledge of one column being sorted by another in the data model. When you sort within an Excel PivotTable, the sorting is done entirely based on the data type, and also takes into account some very important lists that are maintained specifically to facilitate sorting of values that commonly need to be sorted in a special order.
- Whenever you are sorting in Excel, including within PivotTables, Excel does look at sorting lists, and if your data matches those lists, the lists are used instead of regular sorting. There are built-in lists and also custom lists that you can create. The reason that regular month names sort correctly in PivotTables is *not* because you've said to sort a month column by a month number column. It happens because there is a built in list for sorting that contains the twelve names of the months. The following lists are built in to the Excel product: Sun, Mon, Tue, Wed, Thu, Fri, Sat; Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday; Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec; January, February, March, April, May, June, July, August, September, October, November, December. These built in lists is why
- In addition to the built-in lists, you can create your own custom lists to be used for sorting. I have tried this, and if I create a list that includes Oct-15, Nov-15, Dec-15, Jan-16, Feb-16, etc. then sorting of month names in that format will work as you expect.
- Detailed information on how to create custom lists in Excel is available here: https://support.office.com/en-us/article/Create-or-delete-a-custom-list-for-sorting-and-filling-data-D1CF624F-2D2B-44FA-814B-BA213EC2FD61
- We are also considering improving sorting with some other options, but this sort of thing would be a feature in the future, and isn't something that we would be handling as an immediate bug fix.
- I recommend either configuring your data to use the built in lists, or adding a custom list with the month formats that you want. Either approach will work.
Sorry that I didn't realize this when I first posted to this thread, but I'm happy to have figured this out. I hope this helps you to understand what's going on under the cover in PivotTables based on data models in Excel.
Thanks,
-Howie