Recently I’ve been building a lot of Power BI reports from csv and Excel files, and to make sure that scheduled refresh works I have been setting up data sources in an On Premises Data Gateway (what used to be called the Enterprise Gateway). I had assumed that if I was connecting to file-based data sources in my Power BI dataset then, in the gateway, I would need to set up one data source for each file that I’m connecting to – which is a bit of a pain. In fact it turns out that you can set up a gateway data source for the folder that the files are in instead.
Let me give you an example. Imagine that you have three Excel files in a folder called C:\Sales Data:
Now imagine that you have three queries in Power BI that get data from these three files:
Here’s an example of the M code for one of these queries:
[sourcecode language=”text” padlinenumbers=”true”]
, null, true),
However, once the report has been published only one data source needs to be set up in the On Premises Data Gateway for it to refresh successfully, even though the report connects to three different files. Here’s a screenshot of the gateway data source I set up in the Power BI service:
Two things to point out:
- The data source type is set to Folder
- The full path property is set to the path of the folder that the files used by the report are in, ie C:\Sales Data
Setting up a single gateway data source for a folder is obviously a much better option than setting up multiple data sources for all the files in the folder. Did everyone else know this but me? I guess this is all related to the inheritance of data privacy settings that I blogged about here.