cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pchmurzynskivf
Frequent Visitor

A dynamic Source won't refresh in service, but works in desktop

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

 

powerq.jpg

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:


error.jpg

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

1 ACCEPTED SOLUTION
Ailsa-msft
Community Support
Community Support

Hi @pchmurzynskivf 

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

View solution in original post

1 REPLY 1
Ailsa-msft
Community Support
Community Support

Hi @pchmurzynskivf 

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

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors