So this works ok in Desktop, but not in the PBI service.
1. Loads teams with their IDs from a dataflow
2. Uses the "Teams" table to get their IDs and calls a function
3. The function makes api calls for each of the team IDs
1:
let
Source = PowerBI.Dataflows(null),
#"219940f0-94e6-48df-8f25-c4e535cd1ee2" = Source{[workspaceId="219940f0-94e6-48df-8f25-c4e535cd1ee2"]}[Data],
#"dd868909-bd14-46ea-af0f-007c49d48044" = #"219940f0-94e6-48df-8f25-c4e535cd1ee2"{[dataflowId="dd868909-bd14-46ea-af0f-007c49d48044"]}[Data],
Teams1 = #"dd868909-bd14-46ea-af0f-007c49d48044"{[entity="Teams"]}[Data],
#"Sorted Rows" = Table.Sort(Teams1,{{"AnalyticsUpdatedDate", Order.Descending}}),
#"Trimmed Text" = Table.TransformColumns(#"Sorted Rows",{{"TeamName", Text.Trim, type text}})
in
#"Trimmed Text"
2:
let
Source = Teams,
#"Removed Other Columns" = Table.SelectColumns(Source,{"TeamId", "TeamName"}),
#"Invoked Custom Function" = Table.AddColumn(#"Removed Other Columns", "MembersCall", each MembersCall([TeamId])),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Invoked Custom Function", {"MembersCall"}),
#"Expanded MembersCall" = Table.ExpandTableColumn(#"Removed Errors", "MembersCall", {"displayName", "id"}, {"displayName", "id"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded MembersCall",{{"displayName", "User"}, {"id", "UserID"}, {"TeamName", "Team"}, {"TeamId", "TeamID"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"User", type text}, {"UserID", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Normalisation", each "Distinct Active User", type text)
in
#"Added Custom"
3 (function):
First I tried this:
let
Source = (Team_ID as text) => let
Source = Json.Document(VSTS.AccountContents("https://dev.azure.com/vfuk-digital/_apis/projects/digital/teams/" & Team_ID & "/members?api-version=6.0",
[Query = "dev.azure.com/vfuk-digital/_apis/projects/digital/teams/" & Team_ID & "/members?api-version=6.0"])),
value = Source[value],
#"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"identity"}, {"identity"}),
#"Expanded identity" = Table.ExpandRecordColumn(#"Expanded Column2", "identity", {"displayName", "id", "uniqueName"}, {"displayName", "id", "uniqueName"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded identity",{{"displayName", type text}, {"id", type text}, {"uniqueName", type text}})
in
#"Changed Type"
in
Source
But that only worked in Desktop and not in service. Then I tried something different, following the blog post from Chris Webb (about the relative path):
let
Source = (Team_ID as text) => let
Path = "https://dev.azure.com/",
Repath = "vfuk-digital/_apis/projects/digital/teams/"&Team_ID&"/members?",
Source = Json.Document(Web.Contents(Text.From(Path), [RelativePath=Repath, Query=[#"api-version"="6.0"]])),
value = Source[value],
#"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"identity"}, {"identity"}),
#"Expanded identity" = Table.ExpandRecordColumn(#"Expanded Column2", "identity", {"displayName", "id", "uniqueName"}, {"displayName", "id", "uniqueName"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded identity",{{"displayName", type text}, {"id", type text}, {"uniqueName", type text}})
in
#"Changed Type"
in
Source
But the effect is the same. The query will refresh ok in desktop, but when I upload it to Service it gives me this error:
Resources I tried so far:
https://www.excelguru.ca/blog/2015/03/11/power-query-errors-please-rebuild-this-data-combination/
https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power...
https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-i...
https://medium.datadriveninvestor.com/setting-a-scheduled-refresh-on-a-dynamic-data-source-in-power-...
https://hatfullofdata.blog/power-query-dynamic-data-source-and-web-contents/
Please help
Solved! Go to Solution.
Hi @Anonymous
A dynamic data source is a data source in which some or all of the information required to connect cannot be determined until Power Query runs its query, because the data is generated in code or returned from another data source .
In most cases, Power BI datasets that use dynamic data sources cannot be refreshed in the Power BI service.
To determine whether your dynamic data source can be refreshed, open the Data Source Settings dialog in Power Query Editor, and then select Data Sources In Current File. If you see the note “Some data sources may not be listed because of hand-authored queries” , that means the dynamic data source that cannot be refreshed in the Power BI service is present .
Best Regard
Community Support Team _ Ailsa Tao
Anyone develop any other work arounds or methods for better isoloting how/why dymanically constructed URLs can be dealt with or isolated? I've read the cross-join blogs several times, the only thing I haven't tried is the 'fake' ful query so that it 'passes' but I have a sneaking suspicion in my case that would fail.
Part of the issue is I'm also dynamically construction a portion of the main URL as we have multiple servers each in different geos, so it is more than just the [Query] portion that is dyanmic. If I hardcoded each of the geo servers, woiuld that possible help?
Part of the issue is I'm also dynamically construction a portion of the main URL
That is a non-starter. The main URL must be static, and it must yield a 200 response (unless you use a gateway and set to skip the connection test).
Hi @Anonymous
A dynamic data source is a data source in which some or all of the information required to connect cannot be determined until Power Query runs its query, because the data is generated in code or returned from another data source .
In most cases, Power BI datasets that use dynamic data sources cannot be refreshed in the Power BI service.
To determine whether your dynamic data source can be refreshed, open the Data Source Settings dialog in Power Query Editor, and then select Data Sources In Current File. If you see the note “Some data sources may not be listed because of hand-authored queries” , that means the dynamic data source that cannot be refreshed in the Power BI service is present .
Best Regard
Community Support Team _ Ailsa Tao