Forum Discussion
Dynamically Change Workspace Id/Name When Pulling Data Flow
I am reusing the same dataflows in multiple workspaces as well and I'm also looking for a way to dynamically reference the dataflows without having to constantly change al the parameters.
Being able to change only the workspace and have all the dataflows pointing at that workspace would be a start.
I am currently using parameters because I also need to dynamically access those dataflows from other dataflows and it is the ony way Power BI Service would allow me to do it.
The use of parameters reduce the amount of changes I have to do in queries.
But editing the queries is necessary. You could, I guess create a parameter that would be bound to the workspace name and dataflows but you would still need to edit the query in order to update this parameter. ... I think.
I haven't tried this yet, but here's a link to how dynamic parameters works: Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn
*edit* something I just tried with Excel and it worked!:
Create a parameter "WS_PARAMETER" with the workspace name you want to use a default and set it up as a list of values with all the workspaces you want to be able to use.
Create a query named "Dataflows" with this code:
let
Source = PowerPlatform.Dataflows(null),
Workspaces = Source{[Id="Workspaces"]}[Data],
#"Added Custom" = Table.AddColumn(Workspaces, "Dataflows", each [Data]),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([workspaceName] = WS_PARAMETER)),
#"Expanded Dataflows" = Table.ExpandTableColumn(#"Filtered Rows", "Dataflows", {"dataflowId", "dataflowName", "Data"}, {"Dataflows.dataflowId", "Dataflows.dataflowName", "Dataflows.Data"})
in
#"Expanded Dataflows"This table will list all the dataflows available in the workspace you selected, including the "Data" column that contains the entities.
Create another query named after the dataflow you want to use, "DF1" for this example. This query will reference the "Dataflows" query you just created. You can replace the "DF1" value in the #"Filtered Dataflow" instruction to use your dataflow name :
let
Source = Dataflows,
#"Filtered Dataflow" = Table.SelectRows(Source, each ([Dataflows.dataflowName]= "DF1")),
entities = #"Filtered Dataflow"{0}[Dataflows.Data]
in
entities
Then you can reference "DF1" to select the table you want.
I guess if you bind this parameter in your report with the field in the table "Dataflows", it would allow report users to select the source they want to use.
But I only tested it in Excel so far. I can edit after I have tried it using a PowerBI Report.