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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
stribor45
Post Prodigy
Post Prodigy

Paginate API with limit and start - cant apply field access to the type list

I am trying to adopt the code located on this page Paginate REST API  but I am receiving an error. Can someone assist with troubleshooting this error? I am receiving the error: 

 

Expression.Error: We cannot apply field access to the type List.
Details:
    Value=[List]
    Key=total_count

 

let 

    EntitiesPerPage = 100,
	Limit="_limit=" & Text.From(EntitiesPerPage),
    Url = "https://jsonplaceholder.typicode.com/comments?" & Limit,
    GetJson = (Url) =>
        let 			
            RawData = Web.Contents(Url),
            Json    = Json.Document(RawData)
        in  Json,
 
    GetEntityCount = () =>
        let Url   = Url & "&_start=0",
            Json  = GetJson(Url),
			Count = Json[#"total_count"]
        in  
			Count,
 
    GetPage = (Index) =>
        let 
			//(option A)offset equal to previous row count 
			offset  = "&_start=" & Text.From(Index * EntitiesPerPage),      
			Url   = Url & offset,
            Json  = GetJson(Url),
            Value = Json[#"jobs"]
        in  
			Value,
 
    EntityCount =  GetEntityCount(),
    PageCount   = Number.RoundUp(EntityCount / EntitiesPerPage),
    PageIndices = { 0 .. PageCount - 1 },
    Pages       = List.Transform(PageIndices, each GetPage(_)),
    Entities    = List.Union(Pages),
    Table       = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    Table

 

 

1 ACCEPTED SOLUTION
stribor45
Post Prodigy
Post Prodigy

I was able to figure out this so I will mark this as a solution.  I had to break down the code from the link above line by line to figure it out. It was long process. As an example this line 

 

Value = Json[#"jobs"]

 

In my case API provided the total so I had to call it differently

 

Value = Json[#"total_count"]

View solution in original post

2 REPLIES 2
stribor45
Post Prodigy
Post Prodigy

I was able to figure out this so I will mark this as a solution.  I had to break down the code from the link above line by line to figure it out. It was long process. As an example this line 

 

Value = Json[#"jobs"]

 

In my case API provided the total so I had to call it differently

 

Value = Json[#"total_count"]
stribor45
Post Prodigy
Post Prodigy

I had to go through each line of code and was able to get it working but had to block off #1 and #2. I can understand #1 since its pulling the count of only 10 records so it returns the value of 10 but it needs to pull the count of all records which is 500.  In #2 not sure why that piece of code was there. Can anyone comment on #1 and #2 please.

 

stribor45_0-1680719259986.png

stribor45_1-1680719322104.png

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors