Business Intelligence, Data Governance, Mental Health, Diversity, Martial Arts, and Heavy Metal.
Update September 2020: This post gets so many hits every day I decided to make a video. You should watch it. It is short.
Original post:
I try to avoid using Excel as a data source when I can. Although Excel has many benefits [1] , its limitations [2] make it less than ideal for enterprise BI solutions. Despite this, it feels like I end up needing to analyze data in Excel at least once a month. And every time I’m connecting from Power Query to an Excel workbook located in SharePoint Online or OneDrive for Business, I find myself exclaiming “it shouldn’t be this hard!” [3]
What’s the problem? It’s not working with the data – Power Query makes this as painless as you’d expect. The problem is referencing the XSLX file. What path do I use?
In Excel and in SharePoint, there is a “copy link” option, which will copy a link to the workbook so you can share it with others.
It always feels like this should work, that I should be able to paste this URL into the Get Data experience in Power Query, and if it’s been more than a few months since the last time I tried, I expect it to work. But it never does.
In the Excel ribbon, click on the File tab, and on the Info screen that appears click on the label under the file name. There’s no visual indicator that this label is a menu button until you hover over it, but when you click on it, a menu appears with a “Copy path to clipboard” option.
Update May 2020: Since this post was originally published, the Excel team has made this option a little easier to find. Your Excel options may look something like this:
Clicking “Copy path” will give you a path in this format:
With this starting point, all you need to do is remove the ?web=1 query string parameter at the end of the URL, and you have the path to the workbook that Power Query needs.
Choose “Web” as the data source in the Get Data menu, and paste this URL into the Dialog:
Power Query is smart enough to understand that this URL is pointing to an Excel workbook, so from this point on, you’ll get an experience where you can select tables and worksheets, and can start manipulating and analyzing your Excel data.
Full disclosure: Were it not for Power Query program manager Miguel Llopis, I never would have found this. During one of our dataflows sessions at Microsoft Ignite, Miguel spent a few minutes walking through the these steps at the beginning of a demo. My initial reaction was along the lines of “Why are you showing this? This isn’t a dataflows topic!” but when I realized what he was showing it quickly changed to “Holy crap – I didn’t know you could do that!”
In any event, I’m working with data in Excel again today, and spent a few minutes trying to find this technique documented anywhere. When I couldn’t find any, this post was born… but all credit should go to Miguel.
[1] None of which will I list here. It’s not that kind of blog.
[2] Neither will the limitations be enumerated. Feel free to take my word for it, or go build a data warehouse or two that extract data from Excel, and then come back and let me know what you think.
[3] To be fair, this may be another of those “get off my lawn” moments. It’s hard to tell sometimes.