Skip to content

Shaping vs Modelling

Power Query and Power Pivot are two closely related Microsoft tools for self-service business intelligence. They are often confused, because both can change what the data looks like. This page sets out what each one is for.

To keep the two apart, this page uses two words:

  • Shaping means the work done in Power Query, which Excel shows as Get Data.
  • Modelling means the work done in Power Pivot, the engine behind the Data Model.

Shaping is the work of extracting data from where it is kept and transforming it into the form in which it will be loaded. This is most of what ETL, short for extract, transform and load, describes. It is usually the first step of any reporting project.

The shape of the data covers:

  • which data is extracted
  • which tables it is loaded into, and how
  • what the tables and columns are called
  • which tables are short and wide, with many columns, and which are long and narrow, with few

Tables of events, such as sales or purchases, are called fact tables, and they usually work best long and narrow, with many rows and as few columns as possible. Tables that describe things, such as customers, products or employees, are called dimension tables, and they can have as many columns as the reports need.

Either way, a table should hold only the data the reports use.

Shaping data usually means:

  • Restructuring the source tables into the tables the reports need. A relational database is laid out for recording transactions, and that layout rarely suits a reporting tool such as Power BI, so loading the source tables as they are is usually a mistake.
  • Keeping only the columns and rows that are needed. Anything left out can be added later.
  • Occasionally pre-aggregating the data, which means summarising it before it loads. This is sometimes useful but usually best avoided, because the detail is lost.
  • Giving tables and columns names that business users will recognise.
  • Loading the result into the data model.

Where the source is a relational database, the shaping is best done there, in views, so that every report can use it. Where that is not possible, Power Query does the same work.

Modelling starts once the data is loaded. It is the work of relating the tables to each other and turning business requirements into calculations, written as measures and calculated columns in DAX, Power Pivot’s formula language. Those calculations carry:

  • the business logic that turns raw data into a useful figure
  • the number format, such as currency, percentage or whole number
  • a clear business name that says what the figure shows

Before self-service tools, models were built by IT specialists in languages such as MDX, which were too hard for most business users to pick up. DAX is far easier to learn, which is what puts modelling within reach of the people who use the reports.

Modelling usually means:

  • Deciding which data to load and which to leave out.
  • Deciding on the tables: one table, two, or many. A star schema, with one fact table related directly to each dimension table, is the usual aim.
  • Relating the tables to each other where needed.
  • Writing measures that hold the business logic.
  • Formatting measures and columns to suit the business, such as currency, percentage, or a set number of decimal places.
  • Naming each measure so that it says what it calculates.

The decision about what to load is modelling, while the work of structuring the data is shaping. The two depend on each other.

New Power BI users are often confused because a column can be added in more than one place. It can be added in Power Query, or as a DAX calculated column in the model, and a third option is to add it to the source database. Whichever is used, deciding whether the column is needed and what it holds is a modelling decision. Adding the column itself is closer to shaping, although that is open to argument.

The screenshot shows the two places. Power Query’s Add Column tab is the shaping route, and Power BI’s Modeling tab, with its New column button, is the modelling route.

Two ribbons side by side: Power Query’s Add Column tab, labelled shaping, with Column From Examples highlighted, and Power BI’s Modeling tab, labelled modelling, with New column highlighted

The right choice depends on the column. In general, a column is best added as close to the source as possible, which gives this order of preference:

  1. In the source data, such as a data warehouse, with help from IT if needed.
  2. During shaping, in Power Query.
  3. During modelling, in Power Pivot.

A column added at the source is available to every report, now and later. It gives the most reuse and the least upkeep when the logic changes. It is often not an option for self-service work, though, because the source cannot be changed, or cannot be changed quickly enough.

A column added during shaping is compressed along with the other columns as the table loads. The table usually compresses better as a result, which is good for the model as a whole. It also keeps all the shaping in one place, where it is easier to find and maintain.

A column is usually added during modelling when it depends on something already in the model. For example, customers could be banded as high, medium or low by their annual sales, using a Total Sales measure that the model already has.

Doing the same in Power Query takes more work. The query would have to:

  1. join the customer table to the sales table
  2. total the sales for each customer
  3. apply the banding rules
  4. add the band as a column

The model already holds the first two, in its relationships and its Total Sales measure, so a DAX calculated column can reuse them instead of repeating the logic in Power Query. That is the case for a calculated column: it builds on the model’s measures and relationships.

Even so, avoid using calculated columns where a measure would do.

The tools work in sequence. Power Query shapes the raw data, the Data Model, often called Power Pivot, holds it and runs the calculations, and Excel PivotTables or Power BI reports present the results.

The ideas on this page follow Matt Allington’s post Shaping vs Modelling in Power BI on Excelerator BI.