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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
StefanoGrimaldi
Resident Rockstar
Resident Rockstar

Looping with delay timmer between apis call not working

guys Im trying to insert a function between interactions to this code segment; called wait seconds but it doesnt seem to make the wait actually work, any insigt?: 

iterar = List.Accumulate({0 .. numeroIteraciones - 1}, facturas, (state, current) =>
let
id = current * tamanoLote,
headers = [authorization="XXXXXXXXX", accept="application/json"],
facturasObtenidas = ObtenerFacturas(id, headers),
_= Wait_Seconds(20, () => null),
facturasConcatenadas = state & facturasObtenidas
in
facturasConcatenadas
),

 

wait seconds function code: 

//Function to create a timer between interations
let
Wait = (seconds as number, action as function) =>
if (List.Count(List.Generate(() => DateTimeZone.LocalNow() + #duration(0,0,0,seconds), (x) => DateTimeZone.LocalNow() < x, (x) => x)) = 0)
then null else action()
in
Wait





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

3 REPLIES 3
lbendlin
Super User
Super User

That's not how you do delays in Power Query. Use Function.InvokeAfter - PowerQuery M | Microsoft Learn

would appreciate a example of how you would insert the function in the code I pass please @lbendlin 





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




ohh thanks , didnt know of this function will give it a try and come back thanks. 





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.