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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CMS-001
Frequent Visitor

Power Query M - Paginación de API

Hola

Tengo la siguiente consulta:

let

postedFrom = DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-364),"MM/dd/yyyy"),

postedTo = DateTime.ToText(DateTime.LocalNow(),"MM/dd/yyyy"),

Source = Json.Document(Web.Contents("https://api.sam.gov/prod/opportunities/v1/search?limit=1000&api_key=[Key]&postedFrom="&postedFrom&"&postedTo="&postedTo&"&offset=")),

opportunitiesData = Source[opportunitiesData],

#"Converted to Table" = Table.FromList(opportunitiesData, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"noticeId", "title", "solicitationNumber", "department", "subTier", "office", "postedDate", "type", "baseType", "archiveType", "archiveDate", "typeOfSetAsideDescription", "typeOfSetAside", "responseDeadLine", "naicsCode", "classificationCode", "active", "award", "pointOfContact", "description", "organizationType", "officeAddress", "placeOfPerformance", "additionalInfoLink", "uiLink", "links", "resourceLinks"}, {"noticeId", "title", "solicitationNumber", "department", "subTier", "office", "postedDate", "type", "baseType", "archiveType", "archiveDate", "typeOfSetAsideDescription", "typeOfSetAside", "responseDeadLine", "naicsCode", "classificationCode", "active", "award", "pointOfContact", "description", "organizationType", "officeAddress", "placeOfPerformance", "additionalInfoLink", "uiLink", "links", "resourceLinks"}),

#"Expanded officeAddress" = Table.ExpandRecordColumn(#"Expanded Column1", "officeAddress", {"zipcode", "city", "countryCode", "state"}, {"officeAddress.zipcode", "officeAddress.city", "officeAddress.countryCode", "officeAddress.state"}),

#"Expanded placeOfPerformance" = Table.ExpandRecordColumn(#"Expanded officeAddress", "placeOfPerformance", {"state", "zip", "country"}, {"placeOfPerformance.state", "placeOfPerformance.zip", "placeOfPerformance.country"}),

#"Expanded placeOfPerformance.state" = Table.ExpandRecordColumn(#"Expanded placeOfPerformance", "placeOfPerformance.state", {"code", "name"}, {"placeOfPerformance.state.code", "placeOfPerformance.state.name"}),

#"Expanded placeOfPerformance.country" = Table.ExpandRecordColumn(#"Expanded placeOfPerformance.state", "placeOfPerformance.country", {"code", "name"}, {"placeOfPerformance.country.code", "placeOfPerformance.country.name"})

in

#"Expanded placeOfPerformance.country"

y estoy tratando de copiar lo que se logró en este post aquí, pero estoy luchando con cómo implementar la paginación.

  • El límite de registros por página es de 1.000
  • El totalRecords devuelve 46.000 registros

Vea la imagen a continuación:

Power Query M - API Pagination 01.png

Mis intentos de modificar el código de ese otro post hasta ahora no han funcionado. Mi objetivo es generar una tabla con todos los registros que se ve así:

Power Query M - API Pagination 02.png

¿Alguna sugerencia? La documentación de esta API se puede encontrar aquí.

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hola @CMS-001 ,

Consulte la siguiente documentación para manejarlo.

https://datachant.com/2016/06/27/cursor-based-pagination-power-query/

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hola Rena,


Gracias por su respuesta! Desafortunadamente, esa entrada de blog detalla la paginación basada en cursores, mientras que la API con la que estoy trabajando proporciona paginación a través de offset.

Saludos

Dan

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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