Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

How can I setup Pagination in Excel Power Query?

$
0
0

I am importing financial data using JSON from the web into excel, but as the source uses pagination (giving 50 results per page I need to implement pagination in order to import all the results.

The data source is JSON:

    https://localbitcoins.com//sell-bitcoins-online/VES/.json?page=1 
    or https://localbitcoins.com//sell-bitcoins-online/VES/.json?page=2

?page=1, ?page=2, ?page=3

I use the following code to implement pagination, but receive an error:

= (page as number) as table =>
let
    Source = Json.Document(Web.Contents("https://localbitcoins.com//sell-bitcoins-online/VES/.json?page="& Number.ToText(page) )),
    Data1 = Source{1}[Data],
    RemoveBottom = Table.RemoveLastN(Data1,3)
in
    RemoveBottom

When I envoke a parameter (1 for page 1) to test it I get the following error and I can't seem to find out why?

An error occurred in the ‘GetData’ query. Expression.
Error: We cannot convert a value of type Record to type List.
Details:
    Value=Record
    Type=Type

For the record, I try to include page handling using ListGenerate:

= List.Generate( ()=>
[Result= try GetData(1) otherwise null, page = 1],
        each [Result] <> null,
        each [Result = try GetData([page]+1) otherwise null, Page = [Page]+1],
        each [Result])

What is the default way to implement pagination using Power Query in MS Excel?


Viewing all articles
Browse latest Browse all 88054

Trending Articles