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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Begbie
Helper I
Helper I

List.Generate and pagination

Hi All,

 

Wondering if someone can help at all, as I have been trying to do cursor based pagination using the List.Generate function and whilst I initially struggled, I have also realised why I kept getting an error doing it.

 

When the initial API call is made it returns 64,000 rows and a pagination token is created:

"pagination": {
        "next": "bd4b9e12"
    },

 

Give the token and it will then retrieve the next 34,000 rows of data, but the pagination token has now changed from "next" to "previous"

"pagination": {
        "previous": "eaf3358b"
    },

 

When you then try to do the 2nd condition in the List.Generate function, most how-to guides are looking for the value of null on the pagination.next value, but when it gets to the end, the data value doesn't exist as it has now changed to "previous", so the function now throws an error that the "next"field wasn't found

Expression.Error: The field 'next' of the record wasn't found.
Details:
    previous=ff215675

 

The condition being used in the List.Generate:

each [Result][pagination][next] <> null,

 

Any ideas on how to do the condition on this at all?

 

Thanks in advance 😊

4 REPLIES 4
Begbie
Helper I
Helper I

Hi @ppm1 

 

Thanks again for trying to help troubleshoot this and can understand it is hard to work blind on this. I do hope the explainations I have given do help.

 

I have tried the new query you gave above and this has now resulted in:

Begbie_0-1675695914741.png

As always, your help is greatly appreciated 😊

 

Thanks

ppm1
Solution Sage
Solution Sage

How about using try ... otherwise

 

each try [Result][pagination][next] otherwise null <> null,

 

Pat

Microsoft Employee

Thank you @ppm1 seems a different error is now presented:

 

Expression.Error: We cannot convert the value "ead5cb33" to type Logical.
Details:
    Value=ead5cb33
    Type=[Type]

 

Any ideas?

Hard to troubleshoot w/o being to connect myself, but please try this

 

each (try [Result][pagination][next] otherwise null) <> null,

 

Pat

Microsoft Employee

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors