Pivot Table : How to group by date if the column headers are month names?

6,269

Your data is already pivoted and needs to be in a 1d list to pivot it in the way you want. I used to do this on large Cross tab data tables using VBA but this can now be achieved using Power Query:

  1. Select your table range.
  2. Click Data on the ribbon.
  3. Click From Table/Range under Get and Transform Data - your table will be loaded into the Power Query Editor.
  4. Select your columns January through to December and right click the column header - click Unpivot columns You should now have two columns called 'Attribute' and 'Value' Right click 'Attribute' and rename it 'Month'.
  5. You now have a better named table for pivoting.
  6. In excel insert a new PivotTable and under Create PivotTable Check Use an external data source and click Choose connection

Select your Power Query table and you're good to go using the inserted Pivot Table.

Share:
6,269

Related videos on Youtube

Nizar
Author by

Nizar

Updated on September 18, 2022

Comments

  • Nizar
    Nizar over 1 year

    I have a table of expenses for multiple businesses and for each business, the expense is distributed into various accounts. The expenses are reported on a monthly basis; thus the table is provided where the names of the months are the columns' header titles (see Table 1). When using this table to create a Pivot Table, I can't group by date.

    Table 1: Table 1

    I've tried to transpose the Table, but that created two Rows- Column Headers and, thus, can't use it to create a Pivot Table. I have also tried to format the Columns's headers (Months' names) as in DATE Format but that didn't help.

    My objective is to have a Pivot Table that looks like the one shown below.

    Expected Pivot Table: Expected Pivot Table

    Any ideas how to overcome this issue?

  • Nizar
    Nizar over 5 years
    JB, Thank you very much! It worked beautifully.