skip to Main Content

power pivot to power bi

A Power BI Technique Mined from the Power Pivot Archives

Below, you will find one of our all-time favorite Power BI techniques. In the ten (yes ten) years we’ve been operating this site, we’ve written over 1,000 articles on Power BI.  Hard to imagine - even for us - but true.

Years ago, we first wrote up this technique in the context of Power Pivot – Power BI’s cousin and predecessor, which we like to call “Power BI in Excel.” 

Since the two products share the same brains (DAX and M), this technique is more relevant today than ever. Everything below is 100% legit for Power BI – the same data model “shape,” the same DAX, etc. – but now you can use it to power up your Power BI visuals, and not just PivotTables.  Enjoy! Smile


“It’s been a long time since I rock-‘n-rolled…”

-Robert Plant

THE GREAT FOOTBALL PROJECT RETURNS!  Oh yes, it has been a long time indeed.

When I last worked on the football project, I had designed my first report and started the process of better understanding my source data, primarily using the =RELATED() function.  I mentioned a couple of times that the yardage totals being displayed were not yet trustworthy, and that they needed a lot of work before they were accurate.

Let’s get started on making them accurate, because, well, accurate is good.  We like accurate.

A Modest Proposal:  Rushing Yards First

Rather than boil the ocean, let’s start with the simplest type of play in football:  the running play.  Someone takes the football and just runs with it, and hopefully, makes positive progress down the field (measured in yards).  This is often called a “rushing” play, and it generates “rushing yards.”

So ultimately, I want a PivotTable that shows me a list of players, and their Rushing Yards in various situations.

My Source Table Looks Like WHAT??

So far I have just been adding the Yards field to my reports, yielding a Sum of Yards column:

                      PowerPivot Yards by Player

But my source table (the Plays table) typically contains multiple records for a single play, with each record detailing a different player involved in the play, and their role.  Check THIS out:

PowerPivot Multiple Records per Play

Um…  yeah.  There are a multiple rows per play AND a bajillion types of plays.  And they are all mixed in there in one table.  Scanning the screenshot above and applying my knowledge of football, I can say that only ONE row should actually count toward Rushing Yards.

I believe the technical database schema term for this sort of thing is “icky.”  But I don’t think we can blame anyone for this.  Really, football is pretty complex – for a given event, the amount of data that we want to capture can vary tremendously, simply based on what type of play it was, and even based on what HAPPENED on the play.

That’s pretty complex.  But PowerPivot has a secret weapon for this sort of thing.

Und now’s the time on Sprockets when we Calculate!

In traditional Excel, I would solve this problem like this:  I’d create a new column in the Plays table, name it [Rushing Yards], and then use =IF() to give that column a value only when it indeed supposed to count as Rushing Yards.  Then I’d add the Sum of that column to my Pivot.

But as I repeat that process for every other type of yardage – passing, receiving, etc., I’m going to make an already unwieldy table even larger, which makes my life harder (more scrolling) AND increases file size.

In PowerPivot, I don’t have to do that.  I just go straight to the Pivot Table itself and add a new DAX measure:

PowerPivot DAX Measure Using Calculate Function

Let’s zoom in on that formula:

PowerPivot DAX Calculate Function

That’s pretty simple.  The first param is the numerical quantity you are trying to measure – Sum of Yards in this case.  All subsequent parameters are filters/conditions that you want to apply while evaluating that quantity.  Which in this case, is Play Type = “RUN-run”

In the next post, I’ll tell you whether that works 🙂    And explain in more detail what’s going on here.  If my voice is feeling better, I will do it as a video.  But for now the quiet masses who prefer text and pics may rejoice 🙂

Rob Collie

One of the original engineering leaders behind Power BI and Power Pivot during his 14-year career at Microsoft, Rob Collie founded a consulting company in 2013 that is 100% devoted to “the new way forward” made possible by Power BI and its related technologies. Since 2013, PowerPivotPro has rapidly grown to become the leading firm in the industry, pioneering an agile, results-first methodology never before seen in the Business Intelligence space. A sought-after public speaker and author of the #1-selling Power BI book, Rob and his team would like to help you revolutionize your business and your career.

This Post Has 9 Comments
  1. […] more here: DAX's CALCULATE() function – Pivots will never be the same … By pivot | category: pivot, pivot table | tags: down-the-field, field, makes-positive, […]

  2. […] more here: DAX's CALCULATE() function – Pivots will never be the same … By pivot | category: pivot, pivot table | tags: down-the-field, field, makes-positive, […]

  3. It would be interesting to count which play has the largest number of constituent parts? Then try to find the actual video of that play. I imagine it would be something crazy like if a QB got his pass batted back at him, caught it, then took off running, but fumbled it into his own endzone, only to recover the fumble resulting in a Safety. He would then have a pass completion, a reception, a rush, negative rushing yards, a fumble, a fumble recovery and the other team would net 2 points! Hahahaha! All in one play!

    God, I wish I had this updated data set! That should be the new project!

Leave a Comment or Question