One of the concepts I discuss in my new book Learn to Write DAX, is that you should break your DAX problems into manageable pieces so that you can solve the problem one step at a time. Most of us do this intuitively in regular Excel, and it should be no different for Power Pivot and DAX. The trick is to create test measures that are used simply to solve one part of the problem. Once you have worked out…
Post by Rob Collie
First, a Few Quick Updates…
1) Just a reminder that enrollments are open for the live, in-person two-day classes taught by me (Rob) in Indianapolis and Washington DC (in October and November, respectively.) Sign up now – those dates will be upon us sooner than we all realize!
2) The pre-order for DAX 2nd Edition is going Great! Thanks to everyone who has pre-ordered and/or contributed. PRE ORDER HERE if you have not already, and don’t forget the exclusive swag rewards like the sticker, poster, and t-shirt.
3) Ola Freaking Rosling is now using Power BI, and threw us a “shout-out!” OMG, check out this tweet. I nearly peed myself:
If I hadn’t heard so much Anti-Microsoft-Propaganda, I would’ve solved my data-integration faster with Power BI & Power Query @powerpivotpro
— Ola Rosling (@OlaRosling) September 16, 2015
If you don’t recognize the name, his dad is Hans Rosling, the speaker in the first TED talk I ever watched:
Click Image to View the Talk
…In which he did the animated bubble chart demo that I’m 100% positive was the inspiration for Amir Netz adding animated bubble charts in the next two product releases
Here’s Ola and Hans co-presenting on the state of world health and social justice, via data of course:
Again, Click to View the Talk
A celebrity in that Google-y, Apple-y, Silicon Valley-y “doing good with data in the public interest” space using Power BI and saying that Power BI is awesome, and that he’d previously been scared off by all the anti-MS propaganda… well that is simply awesome.
But I won’t lie – that he gave US a mention in that tweet – I *do* find that to be even cooler. I’m human. I can’t help it. I smile every time I think about it.
Slaying the “White Whale” of Variable-Rate Forecasting with PRODUCTX
“Arrrrr! We Be Meeting Again!”
I was helping a friend out recently with an interesting problem. It all started with a SUM( ) that wasn’t behaving. It quickly became a SUMX( ) problem but evolved into a DAX Studio/Query problem. Let me explain.
The Root Problem – Same Store Sales
Many retail businesses open and close stores throughout any given year. This creates a problem because it is difficult to determine if business growth is vertical (increased sales within existing stores) or horizontal (expansion of the store base). It is common to do analysis on “same store sales” where you only include stores that had sales for the entire period this year and also last year. There are quite a few posts already on this topic on PowerPivotPro.com, but this is a good opportunity for me to talk about SUMX and also DAX as a query language. I have reconstructed the scenario with some test data. You can download the workbook here if you want to take a look.
I started off with some base measures as follows:
A. Total Sales:=SUM(Sales[Extended Amount]) B. Total Sales LY:=CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Calendar[Date]))
There are a few different ways to work out sales last year, but I have used SAMEPERIODLASTYEAR above and this works just fine in this instance.
Post by Rob Collie
Does Your Pivot Look Like This? Does its Slow make you Sad? Time for a Fix!
Tell me if this sounds familiar…
Yes, you know that pivots are meant to show aggregations. Summaries. Pivots were NOT invented to display thousands of rows of detail data.
But still, sometimes you need to do precisely that. The biz needs its list of customers and how much they’ve been buying, for instance, and all that data is in YOUR Power Pivot model.
And hey, pivots are really the only game in town* for table-shaped display of data. So, you build one of the monstrosities like the above.
(*OK yeah, you DO know about this thing called DAX Query Tables, but those are seriously a pain to set up. So, no. You rule those out before even starting. Just like me!
So You Do The Flattened Pivot Dance, Right???
In pictorial form…
The Flattened Pivot Option – Found in the PivotTable Dropdown in the Power Pivot Window
Next, You Pile a Whole Bunch of Fields Onto Rows
Then, on the PivotTable Design Ribbon Tab, You Turn Off All Subtotals
And Voila! It’s Slow as Heck.
Post by Rob Collie
Seriously, I Want to Hug the Computer and Every Software Engineer in Redmond
Tales from the Preview
I’m traditionally very slow to look at interim releases of software, but the Office 2016 public preview is out. Everything listed below is now also available to you to look at as well.
Just go grab the preview and slap it on a “spare” computer.
***UPDATE Oct 2015: The preview period is now closed, but this post will help you find a version of Office 2016 that includes Power Pivot.
Rundown of Improvements
The next release of Excel (2016) brings MAJOR improvements to our world. Unlike 2013, which offered us little noticeable benefit over 2010 Power Pivot, I can’t wait for 2016 to become mainstream. It’s a monstrous win.
Each of these improvements warrants its own in-depth blog post, but for now, let’s just run through the list of things that catch my eye…
Measure Icons and Search in the Field List!
We Had Both of these in 2010. 2013 Took Them Away. 2016 Puts them Back
A bit cosmetic perhaps, but if you never used 2010 Power Pivot, you have NO IDEA how useful these are. We welcome them back to our world with open arms.
Even Better: Right Click and Edit Measures in Field List!
This post is based on a query that I got in our monthly Q&A session held for our Online Class attendees.
Input = Multiple quotes for different Products from different Vendors
Desired Output = For each Product show the top three quotes, both price and the Vendor name
A bit more on the Q&A session before we dive in. All our Online Class attendees are invited to a monthly Q&A session, in order to support them in their Power BI journey. Often what you learn in class, you would only apply sometime later. With the Q&A session, if you run into issues or have any questions, you have the opportunity to bring it up and discuss with your instructor. You can sign up for our upcoming Online Live Class on August 3-4.
Step 1: Structuring the Tables
We would clean things up and import the data into separate data and lookup tables. This may seem superfluous for the sample data set, but a real data set could have a lot more rows in the data table and a lot more columns (attributes) for the lookup table. Hence separating the data table and lookup tables is always a good approach.
Step 2: Brainstorm Approach to Writing Measure
If you want to look for trends based on weekday (Sunday…Saturday) or month-of-the-year seasonality (January…December), Cycle Plots can be a potent visualization tool. Some clever folks thought of this back in 1978, but my education on cycle plots has been from Naomi Robbins’ excellent paper. This question was asked during one of our Q&A sessions for the Online Class (Next Class scheduled for Aug 3-4). In this post I’ll discuss the Cycle Plot and then we would build it step by step using Power Pivot. Here is the end result we will achieve (animated gif):
Cycle Plot showing Weekday values for each Week Number and the Average. A slicer also lets the user select the weekday chart should start at
Looking for Periodic Trends
We’ll use sample data showing eight weeks worth of web traffic and we are looking for trends based on the weekday (Sunday…Saturday).
Try 1: We might plot Visitors by Weekday. While this does show the overall pattern of visitors across weekdays, we have no information of how visitor count is changing over those eight weeks.
Try1: No information on how visitors trend changes over the eight weeks
Try 2: We can plot visitors by date. This shows a trend over time and the cyclical pattern is apparent. However, it is hard to track the performance of a single weekday, say Monday over the eight weeks.
Try 2: Hard to track a single weekday (say Monday) over the eight weeks
Try 3: We plot by weekday but add Weeknum as a series. This has a lot of information coded in the graph, but that is also the problem. Viewer is overwhelmed and it is hard to look for the patterns we want to see.
Try 3: A little too much information
A Cycle Plot would show data for each weekday broken by the Weeknum. With the same data now rendered as Cycle Plot, you can see the trend for each weekday and see them in relation with other weekdays. Insights just start hitting you on the head!
1) Friday is the peak traffic day and Mon/Tue are the low traffic days.
2) Thu shows strong growth, especially in the recent weeks
3) Fri shows steady growth
4) Sunday shows a gradual decline (except for last week) and may need closer monitoring
Building a Cycle Plot Using Power Pivot
Post by Rob Collie
From Last Week’s Client Work
Last week a client asked us to solve a somewhat unusual problem: given any two lists of Twitter followers, tell us how many followers “overlap” between the two lists.
How Many of Han Solo’s Followers Also Follow Leia Organa, and Vice Versa?
(Randomly-generated Twitter handles are funny. I particularly like “@Gommo” and “@Xxfok”)
Loading the Data: Using Power Query
Let’s use Power Query to perform the import this time, both because we’re using PQ a lot more around here now that we have Power Update, and because we’re gonna need PQ for the more complex steps later.
Note that all of the steps below are performed using Excel 2013. (I find Power Query to be a bit too clumsy in Excel 2010.)
Importing from a Table Using Power Query: Step 1
(Unchecked “has headers” because of the “Han Solo’s Followers” Row)