Power Pivot is a database that has been designed from the ground up to be optimised for reporting and analysis in Power BI, Power Pivot for Excel and SSAS Tabular. The technology is essentially the same across all of these products so I will generically refer to Power Pivot in this article.
Power Pivot uses an in memory columnar database (Vertipaq) as the foundation technology – the same technology for all versions (Power Pivot, Power BI and SSAS Tabular). The Vertipaq engine is what makes Power Pivot both super fast and highly compressed. A Power Pivot database is not the same as a relational database (RDB) and it does not support all the relationship types that relational databases support. This can be confusing for people that are new to Power Pivot, particularly if they have at least a basic understanding of how databases (such as MS Access) work. I explain what you need to know to get started with relationships in Power Pivot here.
This article is specifically about physical relationships, however there are ways to create virtual relationships using DAX. Examples include using LOOKUPVALUE, FILTER, CROSSFILTER and other techniques. I am not covering these types of relationships in this article.
Relationship Cardinality Types
There are 3 different possible physical relationship cardinality types in database design but not all are supported by Power Pivot.
|Relationship Cardinality Type||Power BI Support||Power Pivot for Excel Support|
|One to Many||Yes||Yes|
|One to One||Yes||No|
|Many to Many||No||No|
One to Many Relationships
The one to many relationship is the foundation of Power Pivot. In the example above (from Adventure Works in Power BI Desktop), the Customers table is on the 1 side of the relationship and the Sales table is on the many side of the relationship. These tables are joined using a common field/column called “CustomerKey”. Customer Key (aka customer number) is a code that uniquely identifies each customer. There can be no duplicates of the customer key in the customer table. Conversely the customer can purchase as many times as needed and hence the customer key can appear in the Sales table as many times as necessary. This is where the name “one to many” comes from – the customer key occurs once and only once in the Customers table but can appear many times in the Sales table.
Tables on the one side of the relationship are called Dimension tables (I call them Lookup tables) and the tables on the many side of the relationship are called Fact tables (I call them Data tables).
The entire Power Pivot Vertipaq engine is optimised to work with this (one to many) type of relationship.
One to One Relationships
The One to One relationship is only supported in Power BI and the newest version of SSAS Tabular. In my view this relationship type has limited value and in most cases it is better to combine these tables into a single flat table prior to loading to Power BI. Consider the model below.
The first relationship (shown as 1) is a 1 to many relationship between the Customer table (Lookup table) and the Sales table (Data table). The Customer Socio Economic Data table is joined to the Customer table via a 1 to 1 relationship (shown as 2 above). If there is a benefit (to the user of reports) of splitting this Socio Economic data into a separate table then of course you should do so. If there is no benefit, I recommend you combine all the data from Customer Socio Economic Data table into the Customer table using Power Query on load.
Every relationship has a “cost” in that it will have some affect on performance. The performance impact may not be noticeable for simple models but may become an issue with very complex models.
If you only remember 1 thing from this article, then please let it be this: Don’t automatically accept the table structure coming from your source data. You are now a data modeller and you need to make decisions on the best way to load your data. Your source system is probably not optimised for reporting (unless it is a reporting datamart) so please don’t assume that what you have got is what you need.
Many to Many Relationships
The many to many relationship type is not supported in Power Pivot. This is a deliberate design decision that has been made as a trade off to ensure optimum database performance. If you have data that is logically related with a many to many cardinality, there are modelling techniques you can use to solve the problem in Power Pivot that are covered in my many to many pattern article here.
There are a few differences in the Power BI Desktop/Excel 2016 UI (relationship view) and that of Excel 2010/2013.
The early UI has an arrow pointing to the lookup table (the one side of the relationship) and a dot on the many side. This is unfortunate as the arrow is pointing in the opposite direction of the filter propagation. This only exists in Excel 2010/2013 (and the early version of SSAS Tabular).
Power BI/Excel 2016
The UI has been significantly improved with Power BI Desktop and Excel 2016. As you can see below, the 1 to many relationship is now clearly shown, and there is also a new arrow showing the automatic filter propagation direction.
One Active Relationship
It is possible to have more than 1 relationship between tables in Power Pivot, but only 1 can be active at a time. An example of when you may want multiple relationships is if you have a Sales[Order Date] and a Sales[Ship Date] in your data table.
In this scenario (shown above in Excel 2013) you may want to join both Sales Date columns to your Calendar table so you can use time intelligence in your data model on both Order Date and Ship Date.
The active relationship is shown as a solid line (above) and the inactive relationship is shown as a dashed line (in this case it is highlighted in blue above). The active relationship is used by default in all DAX measures however you can over-ride this default and use the inactive relationship (when needed) by using the USERELATIONSHIP() function. Full details on this are covered in my article here.
Cross Filtering Behaviour
Power Pivot is optimised to work with one to many relationships and to automatically propagate filters (filter context) from the one side to the many side. In all versions of Power Pivot for Excel, this is the ONLY type of filter propagation that is available.
Power BI supports bi-directional cross filtering behaviour (shown right below) as well as single direction (shown left below).
In fact bi-directional filtering is the default behaviour for Power BI Desktop. There are many people (including me) that think this is a bad idea as bi-directional cross filtering comes at a cost – there is an overhead of constantly cross filtering the lookup table based on the contents of the data table at time when it is actually not required. Sure if you have a simple model and you need this behaviour and you don’t know how to handled it with the many to many pattern then turn it on. But surely this should not be turned on by default. In addition, if you have more than 1 data table, bi-directional cross filtering can cause circular references causing further confusion to unsuspecting users.
I think Microsoft is trying to make Power BI more user friendly for the “lay user” however in this case I think Microsoft has made a mistake. Do yourself a favour and turn off bi-directional cross filtering unless you explicitly need it. To change it just double click on the arrow and set the cross filter direction to single.
update: Last week 17th Feb 2017 I noted that new models I built were single directional by default – seems Microsoft has listened and changed the default behaviour.
Hopefully this article has helped you understand more about how Power Pivot works. Let me know in the comments below if there is anything I have missed.