I’m assuming by environment you’re referring to the SQL environment, correct? Well, it’s maybe not the most elegant way of doing things, but if each environment is linked to a workspace 1-to-1, you could have the query find the workspace and then just perform a simple conditional statement. I’d need to actually test it out on one or two of the workspaces to make sure it worked appropriately, but here’s what I’d do:
Dataflows
let
Source = PowerBI.Dataflows(null),
#"Removed Other Columns" = Table.SelectColumns(Source,{"workspaceId", "Data", "workspaceName"}),
#"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"dataflowId", "dataflowName"}, {"dataflowId", "dataflowName"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded Data",{"workspaceName", "workspaceId", "dataflowName", "dataflowId"}),
#"Pivoted Column" = Table.Pivot(#"Reordered Columns", List.Distinct(#"Reordered Columns"[dataflowName]), "dataflowName", "dataflowId")
in
#"Pivoted Column"
DataflowSettings
let
Source = Dataflows,
#"M Code" = #table(Text.Split(Text.Combine(Table.ColumnNames(Source),", "), ", "), {Text.Split(Text.Combine(Table.TransformColumns(Table.CombineColumns(Source,Table.ColumnNames(Source), Combiner.CombineTextByDelimiter(", ", QuoteStyle.None),"Columns"), {{"Columns", each "" & _ & "", type text}})[Columns], ", "), ", ")})
in
#"M Code"
Workspace List
let
Source = Dataflows[workspaceName]
in
Source
WorkspaceParameter
null meta [IsParameterQuery=true, Type=“Text”, IsParameterQueryRequired=true]
Parameter List
let
Source = PowerBI.Dataflows(null),
#"Removed Other Columns" = Table.SelectColumns(Source,{"workspaceId", "Data", "workspaceName"}),
#"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"dataflowId", "dataflowName"}, {"dataflowId", "dataflowName"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded Data",{"workspaceName", "workspaceId", "dataflowName", "dataflowId"}),
dataflowName = #"Reordered Columns"[dataflowName],
#"Removed Duplicates" = List.Distinct(dataflowName)
in
#"Removed Duplicates"
DataflowParameter
null meta [IsParameterQuery=true, ExpressionIdentifier=#“Dataflow List”, Type=“Text”, IsParameterQueryRequired=true]
fxGetWorkspaceId
let
Source = (pColumn as text, pWorkspace as text) => let
Source = #"DataflowSettings",
#"Filtered Rows" = Table.SelectRows(Source, each [workspaceName] = pWorkspace),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{pColumn}){0},
#"Converted to Table" = Record.ToTable(#"Removed Other Columns"),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Value", type text}}),
Value = #"Changed Type"{0}[Value]
in
Value
in
Source
DataflowID
let
Source = #"DataflowSettings",
#"Filtered Rows" = Table.SelectRows(Source, each [workspaceName] = WorkspaceParameter),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{DataflowParameter}){0},
#"Converted to Table" = Record.ToTable(#"Removed Other Columns"),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Value", type text}}),
Value = #"Changed Type"{0}[Value]
in
Value
Then a standard conditional lookup would determine the environment.