Forum Discussion
Dynamically change data source
- 7 years ago
Hi Anonymous
Yes, your requirement can be achieved.
i make a test.
create parameter called "csvname"
use this parameter in the Advanced editor
Reference:
Power BI – Using Parameters for Flat File / CSV / Excel Sources
https://powerbi.microsoft.com/en-us/blog/deep-dive-into-query-parameters-and-power-bi-templates/
Best Regards
Maggie
Hi Anonymous
As tested, if file "csv1.csv" and "csv2.csv" have the same table structure
(they have the same columns and columns' names, only the values of the cells are different from two files)
for example
csv1.csv
| a | b | c | d | e |
| 1 | 3 | 1 | 1 | 1 |
| 2 | 4 | 2 | 2 |
2 |
csv2.csv
| a | b | c | d | e |
| 10 | 10 | 10 | 10 | 10 |
| 11 | 10 | 10 | 10 | 10 |
Then when you import csv1.csv into Power BI Desktop, and create a visual using columns from it,
You could also change the data source to csv2.csv in the same pbix.
go to Edit Queries->Data source setting->change data sources->click on "Browse"
Select csv2.csv, then click "ok"->click on "apply changes"
Best Regards
Maggie
- Anonymous7 years agoNot applicable
Hi Maggie
Thank you for your reply, that indeed works. But what I am looking for is a little less work (things that can go wrong) if my colleagues applies new sources.
I've heard a little about you can create query parameters, and save the report as a template. So when it opens it will prompt for the location of the .csv files. This is closer to what I am looking for, but would still prefer something similarly to what you can do with Powershell and using the ".\" path that points to the location of the script. Here it would instead be the location of the power-bi report.
- v-juanli-msft7 years agoCommunity Support
Hi Anonymous
Yes, your requirement can be achieved.
i make a test.
create parameter called "csvname"
use this parameter in the Advanced editor
Reference:
Power BI – Using Parameters for Flat File / CSV / Excel Sources
https://powerbi.microsoft.com/en-us/blog/deep-dive-into-query-parameters-and-power-bi-templates/
Best Regards
Maggie