Forum Discussion

maurcoll's avatar
maurcoll
Helper IV
10 months ago
Solved

Only 5000 rows of data loading

Hi

 

I am loading data from a sharepoint online list which is created from a power app, the issue is that Power BI seems to only be loading in the first 5000 rows (incl header row) of data. Any ideas as to why this would be, as far as i can see i have no restrictions in power bi to the amount of data that can be loaded in

  • The SharePoint API that's being used by the connector has a limit of 5000 rows. From what I understand, there are some ways around this.

    1. You can use incremental refresh with a date column.
    2. You can make multiple queries, each with different parameters (e.g. Query1 pulls row 1-4999, Query2 pulls row 5000-9999, etc..) - Basically manual pagination through multiple queries
    3. Make a Power Query which returns everything using pagination (Example code is below)
    4. Lastly you can make a function (just use chatgpt) to dynamically call the API as many times as is needed and then return back the results in 1 query.

    Number 3's Code (Copy and paste this into a blank query in advanced editor - then replace the site url and the list name) :

    let
    // Base site and list
    SiteUrl = "https://yourtenant.sharepoint.com/sites/yoursite",
    ListName = "YourListName",

    // Build base REST URL
    BaseUrl = SiteUrl & "/_api/web/lists/getbytitle('" & ListName & "')/items?$top=5000",

    // Define function to get one page
    GetPage = (url as text) =>
    let
    Source = Json.Document(Web.Contents(url, [Headers = [Accept = "application/json;odata=nometadata"]])),
    Data = try Source[value] otherwise Source,
    NextLink = try Source[#"@odata.nextLink"] otherwise null,
    Output = [Data = Data, NextLink = NextLink]
    in
    Output,

    // Loop through pages
    FirstPage = GetPage(BaseUrl),
    PageList = List.Generate(
    () => FirstPage,
    each [NextLink] <> null,
    each GetPage([NextLink]),
    each [Data]
    ),

    // Combine all pages
    AllData = List.Combine(PageList),
    TableData = Table.FromList(AllData, Record.ToTable, null, null, ExtraValues.Error),
    Result = Table.ExpandRecordColumn(TableData, "Column1")
    in
    Result

5 Replies

  • The SharePoint API that's being used by the connector has a limit of 5000 rows. From what I understand, there are some ways around this.

    1. You can use incremental refresh with a date column.
    2. You can make multiple queries, each with different parameters (e.g. Query1 pulls row 1-4999, Query2 pulls row 5000-9999, etc..) - Basically manual pagination through multiple queries
    3. Make a Power Query which returns everything using pagination (Example code is below)
    4. Lastly you can make a function (just use chatgpt) to dynamically call the API as many times as is needed and then return back the results in 1 query.

    Number 3's Code (Copy and paste this into a blank query in advanced editor - then replace the site url and the list name) :

    let
    // Base site and list
    SiteUrl = "https://yourtenant.sharepoint.com/sites/yoursite",
    ListName = "YourListName",

    // Build base REST URL
    BaseUrl = SiteUrl & "/_api/web/lists/getbytitle('" & ListName & "')/items?$top=5000",

    // Define function to get one page
    GetPage = (url as text) =>
    let
    Source = Json.Document(Web.Contents(url, [Headers = [Accept = "application/json;odata=nometadata"]])),
    Data = try Source[value] otherwise Source,
    NextLink = try Source[#"@odata.nextLink"] otherwise null,
    Output = [Data = Data, NextLink = NextLink]
    in
    Output,

    // Loop through pages
    FirstPage = GetPage(BaseUrl),
    PageList = List.Generate(
    () => FirstPage,
    each [NextLink] <> null,
    each GetPage([NextLink]),
    each [Data]
    ),

    // Combine all pages
    AllData = List.Combine(PageList),
    TableData = Table.FromList(AllData, Record.ToTable, null, null, ExtraValues.Error),
    Result = Table.ExpandRecordColumn(TableData, "Column1")
    in
    Result

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi maurcoll , Thank you for reaching out to the Microsoft Community Forum.

     

    We find the answer shared by pbiuseruk  is appropriate. Can you please confirm if the solution worked for you. It will help others with similar issues find the answer easily.

     

    Also, please refer below docs for your reference:

    Overview of large lists and libraries - Microsoft Support

    Working with lists and list items with REST | Microsoft Learn

    Power Query Web connector - Power Query | Microsoft Learn

    Configure incremental refresh and real-time data for Power BI semantic models - Power BI | Microsoft Learn

    Configure incremental refresh for Power BI semantic models - Power BI | Microsoft Learn

    Living Large with Large Lists and Large Libraries | Microsoft Learn

     

    Thank you pbiuseruk  for your valuable response.

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi maurcoll , Hope you're doing okay! May we know if it worked for you, or are you still experiencing difficulties? Let us know — your feedback can really help others in the same situation.

    • maurcoll's avatar
      maurcoll
      Helper IV

      Hi i changed the way i conncect to the data to use sharepoint list rather than the sharepoint online list which doesnt seem to have the same restrictions on it as all the data is now loading.

      • v-hashadapu's avatar
        v-hashadapu
        Community Support

        Hi maurcoll , Thanks for the update, happy to know everything works fine now. If you have any other queries, please feel free to create a new post. We are always happy to help.