Forum Discussion

Unknown_1's avatar
Unknown_1
Frequent Visitor
1 year ago
Solved

Coupa Power BI Connector

Hi Team,

I have installed the coupa custom power bi connector, to fetch data from coupa.

But the power bi connector has a limitation of fetching 1000 rows at a time only.

Can I fetch more data at one go using pagination?

If so could anybody please guide me in doing so.

Alternatively if there are any other methods I'm open to that.

 

Thanks for the help!

 

Regards,

Pro

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Unknown_1 ,

    For your question, we try to simulate a scenario: in this example, the API can only return 10 pieces of data per page, but we need to get more than 100 pieces of data, we use paging technology, by constantly requesting the data on the next page, until we extract the required amount of data.

     

    let
        // Define a function to fetch data for each page, taking 'page' as a parameter
        FetchData = (page as number) => 
            let
                // Use JSONPlaceholder API to fetch data by specifying the page parameter
                Source = Json.Document(Web.Contents("https://jsonplaceholder.typicode.com/posts?_page=" & Number.ToText(page) & "&_limit=10")),
                Data = Source
            in
                Data,
    
        // Use List.Generate to handle pagination, continuing until no more data is returned
        AllData = List.Generate(
            () => [Page = 1, Data = FetchData(1)],    // Start from page 1
            each List.Count([Data]) > 0,              // Continue fetching while data count is greater than 0
            each [Page = [Page] + 1, Data = FetchData([Page])],  // Increment page by 1 for each new request
            each [Data]                               // Return data for the current page
        ),
    
        // Combine all pages of data into a single list
        CombinedData = List.Combine(AllData),
    
        // Convert the combined list of data into a table
        FinalTable = Table.FromList(CombinedData, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
    in
        FinalTable
    

     

    This approach can be easily extended to other API scenarios such as Coupa, Salesforce, or any other RESTful API that has a paging mechanism. If you have further questions, here's the documentation I've found for you as well as cases that have been solved by the community I hope you find helpful!

    Helper functions for M extensions for Power Query connectors - Power Query | Microsoft Learn

    Solved: Need Help with Stripe REST API Pagination in Power... - Microsoft Fabric Community

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

     

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Unknown_1 ,

    For your question, we try to simulate a scenario: in this example, the API can only return 10 pieces of data per page, but we need to get more than 100 pieces of data, we use paging technology, by constantly requesting the data on the next page, until we extract the required amount of data.

     

    let
        // Define a function to fetch data for each page, taking 'page' as a parameter
        FetchData = (page as number) => 
            let
                // Use JSONPlaceholder API to fetch data by specifying the page parameter
                Source = Json.Document(Web.Contents("https://jsonplaceholder.typicode.com/posts?_page=" & Number.ToText(page) & "&_limit=10")),
                Data = Source
            in
                Data,
    
        // Use List.Generate to handle pagination, continuing until no more data is returned
        AllData = List.Generate(
            () => [Page = 1, Data = FetchData(1)],    // Start from page 1
            each List.Count([Data]) > 0,              // Continue fetching while data count is greater than 0
            each [Page = [Page] + 1, Data = FetchData([Page])],  // Increment page by 1 for each new request
            each [Data]                               // Return data for the current page
        ),
    
        // Combine all pages of data into a single list
        CombinedData = List.Combine(AllData),
    
        // Convert the combined list of data into a table
        FinalTable = Table.FromList(CombinedData, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
    in
        FinalTable
    

     

    This approach can be easily extended to other API scenarios such as Coupa, Salesforce, or any other RESTful API that has a paging mechanism. If you have further questions, here's the documentation I've found for you as well as cases that have been solved by the community I hope you find helpful!

    Helper functions for M extensions for Power Query connectors - Power Query | Microsoft Learn

    Solved: Need Help with Stripe REST API Pagination in Power... - Microsoft Fabric Community

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.