Skip to content

Introduction

This series follows on from Starting with ETL. That guide covers the everyday transformations, so this one moves on to the harder problems that come up when real files have to be combined, reshaped and kept working as they change.

The techniques in this series were first worked through using the examples in Gil Raviv’s Collect, Combine, and Transform Data Using Power Query in Excel and Power BI (Microsoft Press), and the sample data in the screenshots comes from the book’s exercise files.

Each page takes one problem and solves it in Power Query, and most of them build on the page before:

  1. Combining mismatched tables. Tables that hold the same kind of data often disagree on their column names. A conversion table maps the old names to the new ones, so the tables can be appended cleanly.
  2. Preserving context. Some of the meaning in a file sits outside its table, in a file name, a sheet name or a label above the table. This page finds a category label above each sheet’s table, however far down it is, and carries it into the data as a column.
  3. Transforming data into tables. A report layout is easy to read but hard to analyse. This page explains what a well-shaped table looks like and why, and uses Unpivot to get there.
  4. Generalised unpivoting. A summary table with more than one row of headers needs more than a single Unpivot. This page unpivots a table whose rows and columns both carry several levels of headings.
  5. A generalisable function. The steps from the previous page are turned into a custom function, so any table with the same kind of layout can be unpivoted in one call.
  6. Slowly changing datasets. Queries break when the source files change shape. This page collects habits that keep a query working when columns are added, renamed or moved.
  7. The challenge. An exercise that combines yearly revenue files in different formats and layouts into one table, using the techniques from the earlier pages.
  8. Data cop. An exercise in finding out which rows of a dataset have been tampered with, by comparing it with a trusted copy.