Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
anuradha01
Helper I
Helper I

Unable to set refresh schedule for report with sharepoint list

Hi Community 

I need to build Power BI reports using data collected in SharePoint lists via a Power app.

Initially, I used a Sharepoint list connector to get data from the online Sharepoint list but data refresh was too slow.

Then I implemented the below function to connect to the sharepoint list which made the refresh on the PBI desktop much faster-

= (tenant_name,site_name,list_name)=>
let
tenantname = tenant_name,
sitename = site_name, // if a subsite use "Site/SubSite"
listname = list_name,
baseurl = "https://" & tenantname & "/sites/" & sitename & "/_api/web/lists/GetByTitle('" & listname & "')/",
itemcount = Json.Document(Web.Contents(baseurl&"ItemCount", [Headers=[Accept="application/json"]]))[value],
skiplist = List.Numbers(0, Number.RoundUp(itemcount/5000), 5000),
#"Converted to Table" = Table.FromList(skiplist, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Skip"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Skip", type text}}),
fieldselect = "&$top=5000", // all fields with no expansion
#"Added Custom" = Table.AddColumn(#"Changed Type", "Items", each Json.Document(Web.Contents(baseurl& "/items?$skipToken=Paged=TRUE%26p_ID=" & [Skip] & fieldselect, [Headers=[Accept="application/json"]]))),
#"Expanded Items" = Table.ExpandRecordColumn(#"Added Custom", "Items", {"value"}, {"value"}),
#"Expanded value" = Table.ExpandListColumn(#"Expanded Items", "value")

in
#"Expanded value"

 

However now the issue is I am unable to schedule auto refresh on PBI service it says 

"This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service, this dataset won't be refreshed. Learn more: https://aka.ms/dynamic-data-sources.

  • Data source for Query1"

Can you please suggest a solution to ensure the data source connection is faster and i can schedule auto refresh on PBI service as well?

 

Please let me know incase any other details are required.

 

Thanks & Regards

Anu

 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Please follow the documentation. Use RelativePath and Query parameters. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-1

View solution in original post

Query parameters should go into the Query section, not the RelativePath section.

 

Delete things that are not relevant (like baseurl).  Make sure your rooturl is actually callable by itself.

View solution in original post

9 REPLIES 9
danextian
Super User
Super User

Hi @anuradha01 

 

The issue arises because Power BI service does not support dynamically constructed URLs. You will need to use Web.Contents relative paths options.

let
    tenantname = tenant_name,
    sitename = site_name, // if a subsite use "Site/SubSite"
    listname = list_name,
    baseurl = "https://" & tenantname & "/sites/" & sitename & "/_api/web/lists/GetByTitle('" & listname & "')/",
    
    // Define root URL separately for Power BI service compatibility
    rootUrl = "https://" & tenantname & "/sites/" & sitename & "/_api/",
    
    // Fetch item count with a relative path
    itemcount = Json.Document(Web.Contents(rootUrl, [RelativePath = "web/lists/GetByTitle('" & listname & "')/ItemCount", Headers = [Accept = "application/json"]]))[value],
    
    skiplist = List.Numbers(0, Number.RoundUp(itemcount / 5000), 5000),
    #"Converted to Table" = Table.FromList(skiplist, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table", {{"Column1", "Skip"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns", {{"Skip", type text}}),
    
    fieldselect = "&$top=5000", // all fields with no expansion
    
    // Fetch paginated items using a relative path
    #"Added Custom" = Table.AddColumn(
        #"Changed Type", 
        "Items", 
        each Json.Document(
            Web.Contents(rootUrl, 
                [RelativePath = "web/lists/GetByTitle('" & listname & "')/items?$skipToken=Paged=TRUE%26p_ID=" & [Skip] & fieldselect, 
                 Headers = [Accept = "application/json"]
                ]
            )
        )
    ),
    
    #"Expanded Items" = Table.ExpandRecordColumn(#"Added Custom", "Items", {"value"}, {"value"}),
    #"Expanded value" = Table.ExpandListColumn(#"Expanded Items", "value")

in
    #"Expanded value"

 More on Web.Contents - https://learn.microsoft.com/en-us/powerquery-m/web-contents 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi Dane

 

Thank you for the prompt response.

I replaced the code with the one you shared but still it gives same error when I am trying to set automatic refresh.

Can you please share if there is some other workaround for the same?

 

Thanks 

Anu

Please follow the documentation. Use RelativePath and Query parameters. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-1

I did used relative path but still its not allowing to set auto refresh.

 

let
    tenantname = tenant_name,
    sitename = site_name, // if a subsite use "Site/SubSite"
    listname = list_name,
    baseurl = "https://" & tenantname & "/sites/" & sitename & "/_api/web/lists/GetByTitle('" & listname & "')/",
    
    // Define root URL separately for Power BI service compatibility
    rootUrl = "https://" & tenantname & "/sites/" & sitename & "/_api/",
    
    // Fetch item count with a relative path
    itemcount = Json.Document(Web.Contents(rootUrl, [RelativePath = "web/lists/GetByTitle('" & listname & "')/ItemCount", Headers = [Accept = "application/json"]]))[value],
    
    skiplist = List.Numbers(0, Number.RoundUp(itemcount / 5000), 5000),
    #"Converted to Table" = Table.FromList(skiplist, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table", {{"Column1", "Skip"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns", {{"Skip", type text}}),
    
    fieldselect = "&$top=5000", // all fields with no expansion
    
    // Fetch paginated items using a relative path
    #"Added Custom" = Table.AddColumn(
        #"Changed Type", 
        "Items", 
        each Json.Document(
            Web.Contents(rootUrl, 
                [RelativePath = "web/lists/GetByTitle('" & listname & "')/items?$skipToken=Paged=TRUE%26p_ID=" & [Skip] & fieldselect, 
                 Headers = [Accept = "application/json"]
                ]
            )
        )
    ),
    
    #"Expanded Items" = Table.ExpandRecordColumn(#"Added Custom", "Items", {"value"}, {"value"}),
    #"Expanded value" = Table.ExpandListColumn(#"Expanded Items", "value")

in
    #"Expanded value"

 

Hi @anuradha01,

 

We haven’t heard back from you regarding your issue. If it has been resolved, please mark the helpful response as the solution and give a ‘Kudos’ to assist others. If you still need support, let us know.

 

Thank you.

Hi @anuradha01,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

Hi @anuradha01,
I wanted to check if you had the opportunity to review the information provided by @lbendlin @danextian . Please feel free to contact us if you have any further questions. If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

Query parameters should go into the Query section, not the RelativePath section.

 

Delete things that are not relevant (like baseurl).  Make sure your rooturl is actually callable by itself.

lbendlin
Super User
Super User

Please follow the documentation. Use RelativePath and Query parameters. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-1

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.