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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
MichaelHutchens
Helper IV
Helper IV

Combining multiple SharePoint SitePage libraries into a single query

Hi everyone, I manage an intranet with 10 subsites. I'm looking to create a single PowerBI table that combines basic information from every library, without having to load every single library and then append them into one query.

 

Here's my code for the first library:

 

 

let
    Source = SharePoint.Tables("https://URL/", [Implementation=null, ApiVersion=15]),
    #"793529eb-48c3-4fad-a005-7a4aa0a716ad" = Source{[Id="793529eb-48c3-4fad-a005-7a4aa0a716ad"]}[Items],
    #"Renamed Columns" = Table.RenameColumns(#"793529eb-48c3-4fad-a005-7a4aa0a716ad",{{"ID", "ID.1"}}),
    #"Expanded File" = Table.ExpandRecordColumn(#"Renamed Columns", "File", {"LinkingUri", "LinkingUrl", "Name", "ServerRelativeUrl", "Title"}, {"File.LinkingUri", "File.LinkingUrl", "File.Name", "File.ServerRelativeUrl", "File.Title"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded File",{"File.ServerRelativeUrl"})
in
    #"Removed Other Columns"

 

My question is, is it possible to modify the code above to include these additional SitePage libraries (as an example):

Any alternate suggestions about how to load multiple similar tables from different SharePoint sites into one PowerBI reporting table would be much appreciated 🙂 Thanks so much 🙂

1 ACCEPTED SOLUTION

Then you should be able to write a query along these lines:

let
    Source = Table.Combine(
        {
        SharePoint.Tables("https://URL/sites/sitename1/", [ApiVersion = 15]),
        SharePoint.Tables("https://URL/sites/sitename2/", [ApiVersion = 15]),
        SharePoint.Tables("https://URL/sites/sitename3/", [ApiVersion = 15])
        }
    ),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Title] = "Site Pages")),
    #"Expanded Items" = Table.ExpandTableColumn(#"Filtered Rows", "Items", {"File"}, {"File"}),
    #"Expanded File" = Table.ExpandRecordColumn(#"Expanded Items", "File", {"ServerRelativeUrl"}, {"File.ServerRelativeUrl"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded File",{"File.ServerRelativeUrl"})
in
    #"Removed Other Columns"

View solution in original post

4 REPLIES 4
MichaelHutchens
Helper IV
Helper IV

Perfect, thank you so much @AlexisOlson! 🙂

AlexisOlson
Super User
Super User

I'm pretty sure you'll have to call SharePoint.Tables("URL",...) for each separate site but you can still do that in a single query if you want to.

 

It looks like you're loading a specific list. Is there an analogous one in each site with the same/similar Title?

Hi @AlexisOlson , correct the above is a specific list. Here's a sample of three more analogous ones from each site:

https://URL/sites/sitename1/SitePages/
https://URL/sites/sitename2/SitePages/
https://URL/sites/sitename3/SitePages/

Then you should be able to write a query along these lines:

let
    Source = Table.Combine(
        {
        SharePoint.Tables("https://URL/sites/sitename1/", [ApiVersion = 15]),
        SharePoint.Tables("https://URL/sites/sitename2/", [ApiVersion = 15]),
        SharePoint.Tables("https://URL/sites/sitename3/", [ApiVersion = 15])
        }
    ),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Title] = "Site Pages")),
    #"Expanded Items" = Table.ExpandTableColumn(#"Filtered Rows", "Items", {"File"}, {"File"}),
    #"Expanded File" = Table.ExpandRecordColumn(#"Expanded Items", "File", {"ServerRelativeUrl"}, {"File.ServerRelativeUrl"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded File",{"File.ServerRelativeUrl"})
in
    #"Removed Other Columns"

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.