简体   繁体   中英

Excel PivotTable bug? If Text column of source table has a month name, it breaks the A-Z sort in the pivot table

I have an Excel file which I can share with you, but here is how to recreate it:

  1. In a workbook tab, create a table called "DataTable" with the two "Company" and "Score" columns as shown below.

  2. Format the "Company" column explicitly as "Text". You can even precede the entries with single quotes to force Excel to treat them as Text : it won't change the behavior.

  3. Below this table, create a simple PivotTable on "DataTable" with "Company" as a Row Field and "Sum of Score" as a Value Field.

  4. In the PivotTable, Sort the "Row Labels" (Company) field "AZ".

  5. You will see this, where the values "DEC" and "SEP" bubble to the top above the other AZ values:

数据透视表错误的屏幕截图

What apparently is happening is that Excel insists on treating anything that looks like a month name or abbreviation as its numeric equivalent, which sorts above the other AZ text values.

  • Question 1: Is this a confirmed bug?
  • Question 2: How can I keep the desired values (like "SEP") but stop this from happening?

I am happy to upload an actual simple spreadsheet which shows this behavior. Thanks!

  1. Click on Row Labels Filter
  2. Select More Sort Options
  3. Select More Options (Bottom Left)
  4. Uncheck Sort Automatically every time the report is updated
  5. Ensure First key sort order = No Calculation
  6. Refresh Pivot Table

在此处输入图片说明

That's because Excel thinks SEP and DEC are months names and sorts them according to Custom Lists . To prevent this, you need to go to PivotTable -> Options and uncheck Use custom Lists when sorting in the Totals & Filters tab

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM