2
votes

Can you tell me if it is possible to keep the reports from one PowerBI (Desktop version) and just change the data source to display the same data (report) in the same way but from two different sources. This will basically mean I will have a "template" PowerBI which I can connect to any data source (having the same data of course).

Or is the only way of doing this just recreating the widgets on a new report for every new data source?

Thanks, G

1
In this moment that is not possible. If you delete a datasource or the connection is broken the asociated charts will dissapear. There is an active suggestion to Power BI team here. Maybe we can see that feature soon in a coming update.alejandro zuleta
thanks @alejandrozuleta, it's also good to know there was an idea forum :)GaGa

1 Answers

2
votes

There's a pattern you can use to make this work reasonably well. When you go to the queries view in Power BI Desktop, when you right click the query there is a 'reference' option. What this does is create a new query where the initial state is the result of the referenced query. This is very powerful!

So then what you can do is have your first query be something like: let Source = OData.Feed("feedname") in Source

Then build all your other queries using that one query. This will let you quickly change the source without disturbing any of your other logic.

You can take this to ever more crazy extents as desired. For example, for some time I would receive exported .CSV files in email from one of the service I was using. To 'update' my report, I would need change my report to pull data from the new file (a pain). So what I did was I made a set of queries that 1) listed the files in a given folder, 2) selected the most recent file, 3) loaded the data from that most recent file. So long as the schema of the file did not change, everything worked great!

First Query:

    let
            FilesList = Folder.Files("C:\Users\username\Report Data"),
            c1 = Table.TransformColumnTypes(FilesList ,{{"Date created", type datetime}}),
            c2 = Table.SelectRows(c1, each Text.Contains([Extension], ".csv")),
            c3 = Table.Sort(c2,{{"Date created", Order.Descending}}),
            LatestCSVFileTable = Table.FirstN(c3,1),

            AddedFileName = Table.AddColumn(LatestCSVFileTable , "File Path", each [Folder Path] & [Name]),
            LatestCSVFileNameAsTable = Table.RemoveColumns(AddedFileName,{"Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),
            FileNameToLoad = Record.Field(Table.First(LatestCSVFileNameAsTable), "File Path"),

//If you're lucky, you can just use Csv.Document(File.Contents("C:\Examples\YourFileName.csv"),null,",",null,1252)
//I wasn't so I needed some more complicated logic

            FileContents = File.Contents(FileNameToLoad),
            Source = Table.FromColumns({Lines.FromBinary(FileContents ,null,null,1252)}),
        in
            Source

Second Query

let
    Source = #"First Query's Name"
    // continue your logic here 
in 
   Source

This approach works great. I usually put the first query in a folder I call "RAW" and the second query in a folder I call "Data" so I know which ones to edit and which to leave alone.