Forum Discussion

avi081265's avatar
avi081265
Helper III
3 years ago
Solved

How to combine SharePoint List from multiple SharePoint sites

Hello    I want to combine SharePoint List from different SharePoint sites. All the list having same kind of structure. My Idea that I will create one SharePoint LIst which we will have four column...
  • Anonymous's avatar
    Anonymous
    2 years ago

    I cannot share the pbix sample but I can provide the explanation of the code:

    The code is designed to fetch data from multiple SharePoint lists based on the URLs and list names provided in an Excel file.

    The first part of the code reads an Excel file. This Excel file contains a list of SharePoint site URLs and corresponding list names. The Excel.Workbook function is used to load the Excel file, and the Table.RenameColumns function is used to rename the columns to "Site URL" and "List Name".

    Next, a custom function named FetchList is defined. This function takes a SharePoint site URL as an argument and returns a table of all lists in the SharePoint site. The SharePoint.Tables function is used to fetch the lists from the SharePoint site.

    Finally, a new column named "Custom" is added to the table. For each row in the table, the FetchList function is called with the site URL from that row. The result is a table with an additional column that contains the SharePoint lists for each site URL.

    This code is a common pattern in Power Query M language for fetching and combining data from multiple sources based on a list of parameters.