Change Excel Source in Power BI to OneDrive for Business – No Gateway Needed

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube

If you used an excel file in a local source (or even OneDrive for Business, but sourced locally), you need to do one extra step to make your query refreshable without the need to the gateway. Here in this blog post, I’ll explain an easy way to do that change. If you want to learn more about Power BI, read Power BI book from Rookie to Rock Star.

On-Premises(Local) Excel Source

In the example below, I have created a Power BI report with Get Data from Excel, and I used the Excel file that is located in my OneDrive for Business directory:

After building the report, and publishing it to the Power BI service, in the schedule refresh, you will get to the place that you need to connect it to a gateway

You cannot schedule refresh the report unless you set up a gateway! If you don’t know what the gateway is, here is brief information about it: Gateway is an application that creates a connection from the Power BI dataset in the service to the local domain (on-premises) data source. Here in this article, I explained everything you need to know about the gateway.

As you see in the above expression, the gateway is needed for data sources that are on-premises. One Drive for Business is not an on-premises data source. So why do you get this issue of needing to set up the gateway? The reason is that our file is not sourced from OneDrive for Business. It is sourced from a local folder. To see where the data source of your Power BI leaves, click on Data Source Settings under the Transform Data in the Power BI Desktop.

Here you can see all the data sources, and you can click on any of those to change if you want to.

As you can see, the source in the above file is a local file in my local folder in C drive! Even though I have selected it from the OneDrive for Business folder, it is still pointing to the local folder representative of that. and as long as the local folder is the source, the gateway is need to get it refreshed in the service. Here is the quick solution for you.

Solution: Change Source to Web Query

You can change the source of your excel file to a web query, but you need to have the web URL address of that file. Here is how you can get it:

Find the Web URL Source

Open the Excel file locally, and then go to File menu, under Info, right-click on Open File Location, and then Copy Path.

The path should look like this (paste it into a notepad window):

https://xyz-my.sharepoint.com/personal/reza_radacad_com/Documents/Data Sources

You need to use this path now as the source

Change the Source to the Web.Contents

Go to Transform Data section of Power BI Desktop

In the Power Query Editor window, click on the Source step of your query.

If you don’t see the formula bar, go and enable it in the View tab;

Now change the File.Contents(“…”) part of the formula above with Web.Contents(“…”)

here is how I change mine from:

to this:

Note that the address inside the Web.Contents are coming from the path that you have copied in the notepad in the previous step plus a forward slash (/), and then the file name and extension.

Web.Contents(“<path copied in the previous step>/filename.xlsx”)

And note that the Web should be written with capital “W”, and lowercase “eb”.

After doing this change for all your queries that are coming from the file from OneDrive, then click on Close and Apply in the Home tab.

Now this time, after publishing it to the service, in the Schedule Refresh tab, you can see that the gateway configuration is disabled, and you just need to Edit Credentials under Data Source credentials.

 

Set the credentials with OAuth2, and Sign in with the account which has access to the OneDrive for Business folder;

Now you can schedule the dataset to refresh (without the need to gateway):

Or you can run the refresh manually to test if it works fine.

I hope the method mentioned in this quick blog post, helps you in your Power BI implementation.

Video

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube
Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for nine continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He wrote some books on MS SQL BI and also is writing some others, He was also an active member on online technical forums such as MSDN and Experts-Exchange, and was a moderator of MSDN SQL Server forums, and is an MCP, MCSE, and MCITP of BI. He is the leader of the New Zealand Business Intelligence users group. He is also the author of very popular book Power BI from Rookie to Rock Star, which is free with more than 1700 pages of content and the Power BI Pro Architecture published by Apress.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.

14 thoughts on “Change Excel Source in Power BI to OneDrive for Business – No Gateway Needed

  • Hi Reza – thank you for this – it was very helpful.
    What if your data source also contains a SQL server for importing the data? Are there other steps I would need to take?
    Thank you
    Chris

    • For SQL Server, if it is on-premises SQL Server, then you need the gateway for sure.
      if it is Azure SQL DB, you just need a server name or IP, with no gateway needed.
      so either way, no change is needed in Power Query
      Cheers
      Reza

  • Great solution Reza👍🏼
    Do you know if it’s possible when using dataflows with on prem data?

    /Sainey

  • Hi Reza, first of all, Happy New Year! Wish you and your family a health and happy new year of 2020.
    Thanks for the detailed instruction in this post. I’ve tried to do something similar… changed the data source to SharePoint Folder; and publish the report to on-premise report server. However, when I tried to edit the credential, it keeps telling me my credential is incorrect. I was sure I had input my password correctly. Nevertheless, I am not sure if I have input the rest correctly. Wondering if you could point me to the right direction. Appreciate it.
    Thanks.
    MF

    • Hi MF
      Happy New Year!
      The implementation you are talking about seems different. You are working with Folder (SharePoint Folder), and your report is going to be hosted on the Power BI report server.
      However, I think that still should work as long as the data source is supported (I haven’t tested SharePoint folder data source on-prem to see is it working or not)
      What credentials did you use? have you selected Microsoft (OAuth) credentials?

      Cheers
      Reza

  • Hi Reza. May I first wish you a happy new year. Thank you a gain for this great post. Refreshing my report is a kind of nightmare for me.
    I didn’t implemented yet your proposal but what is specific to my own case is that I used to be implementing function to folder from my OneDrive for Business contains my daily files.
    Can I still be using your described procedure?
    Thank.

    • Hi.
      Happy New Year to you too 😊
      Yes, you can still use this approach.
      Or, alternatively, you can use SharePoint.Files function in Power Query to get all the files from the OneDrive for Business folder you want. I might write a blog post about that method too.
      Cheers
      Reza

  • OAuth2 is not available for me – it’s not in the dropdown list. Only Anonymous, Windows and Basic and none of them let me through.

Leave a Reply

%d bloggers like this: