Using 'parameters' in #PowerBI as a relative data source path
Mohammad Taimur, CMA, CISA
Treasury & Investments | Capital Management | Strategic Finance
In data analytics, the efficiency and flexibility for data sources (aka. data pipelines) are of paramount importance. Power Query in Power BI does not support relative paths as data sources, which can lead to cumbersome workflows in some use cases, especially when dealing with multiple queries that rely on the same data source. For instance, if you have a collection of Excel files stored in a specific folder, changing the source path for each query can quickly become a tedious task. This article suggests a simple yet effective solution that can streamline this process: using parameters.
The Problem
Typically, data source is specified as an absolute path like:
Source = Folder.Files("C:\Users\me\projects\Automation & BI\EasyApplyBot")
Now imagine that several queries depend on this path, and you have to change location of source data files for a reason. Result? You will have to update multiple queries to ensure your dashboard picks the data from new location.
But here’s where a small trick comes in—using parameters to create a dynamic and flexible source path. By implementing this approach, you save time and avoid the redundancy of updating each individual query. Here is now it works:
The Solution
Define a parameter and specify absolute path to data source and then use that parameter in all the queries that depend on that data source. Once queries are pointed to use parameter, you will only need to update parameter to update all dependent queries.
First step is to define parameter called 'param_data source' as shown in figure 1:
领英推荐
Once the parameter is defined, you can point your query to read data from the parameter as:
Source = Folder.Files(#"param_data source")
The Advantage?
Instead of manually changing the source for every query, you just change one parameter to have all the dependent queries relatively updated using the parameter. This simple yet effective technique adds significant flexibility to your workflow and makes managing multiple data sources a breeze.
#DataScience #DataAnalytics #BusinessIntelligence #PowerQuery
--
My Python projects: https://github.com/voidbydefault/