Skip to content

Transition Tables

This page shows what a transition table is, and when it helps: loading data whose column headers change.

Excel tables, introduced in Excel 2007, make it much easier to organise a block of structured data and to refer to it in formulas. They have one limitation, though, which is that their header row holds fixed values. A table’s headers cannot be formulas, so they cannot change when something else in the workbook changes.

The worksheet below records a small media company’s subscriptions by month. The date in C1 drives the month-end dates across row 3, so changing that one cell updates every header:

A worksheet with a Most recent budget supplied date of 01/01/2014 in C1, and below it a Month header row of month-end dates from 31/01/2014, above four rows of subscription counts

The aim is to load rows 3 to 7 into Power Query and unpivot them, but two obstacles stand in the way:

  • Turning the range into an Excel table would fix the headers as values, so the formulas in row 3 would stop working.
  • Loading it as a named range would keep the formulas, but the query would break when the dates changed, because its steps refer to the column headers by name.

A transition table gets round both. It is a separate Excel table that lists stable period codes beside the formula-driven dates. The source data is labelled with the stable codes, so the query never sees a changing header, and a merge with the transition table brings the real dates back in.

Create an Excel table like this one, with a period code and its date on each row:

An Excel table with columns Period and Date, mapping CYM1 to 31/01/2014 through CYM12 to 31/12/2014

Power Query needs a query for this table before it can merge with it:

  • Select any cell in the table.
  • Create a new query with From Table/Range.
  • On the Home tab, click Close & Load To, and choose Only Create Connection.

2. Add the period codes to the source data

Section titled “2. Add the period codes to the source data”

The source data now needs headers in the same CYM form:

  • Insert a new row below row 3.
  • Copy the values in the transition table’s Period column, and paste them into the new row with Paste Special, ticking Transpose.

The worksheet with a new row 4 holding the codes CYM1, CYM2, CYM3 and onwards under the month-end dates

Next, make a table from rows 4 to 8, leaving row 3 outside it so that its formulas keep working:

  • Click inside the data, and on the Insert tab click Table.
  • Change the range to =$B$4:$N$8.
  • Click OK, and name the table Customer_Data.
  • Hide row 4.

The worksheet looks as it did before, but the data below the dates is now a table with fixed headers:

The worksheet with row 4 hidden, showing the Month row of dates directly above the subscription rows, which now sit in a table

  • Click inside the Customer_Data table and create a new query with From Table/Range.
  • Right-click the first column and choose Unpivot Other Columns.

The Attribute column now holds the period codes, which can be matched against the transition table:

  • On the Home tab, click Merge Queries.
  • Choose the transition table as the second table.
  • Select the Attribute column in the first table and the Period column in the second, and click OK.
  • Expand the new column, taking only the Date field and unticking the option to use the original column name as a prefix.
  • Right-click the Date column and choose Change Type, then Date.
  • Right-click the Attribute column and choose Remove.
  • Right-click the Value column, choose Rename, and call it No. of Customers.
  • Give the first column a suitable name, such as Length of Subscription.
  • Rename the query to Budget.
  • On the Home tab, click Close & Load.

The result is an unpivoted table that gives the right date for each subscription count:

The loaded table with columns Length of Subscription, No. of Customers and Date, listing Full Year Subscriptions for each month-end of 2014

Now change the date in C1 to 2020:

The worksheet with C1 set to 01/01/2020, so the Month row shows month-end dates from 31/01/2020

Refresh the query, and the dates in the unpivoted table follow:

The refreshed table with the same counts, now dated 31/01/2020 to 31/12/2020, including 29/02/2020