web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Dividing a Batch of 20...
Power Automate
Unanswered

Dividing a Batch of 200 SQL Result Rows and sending 50 Result Rows each into 4 Outlook emails containing records into HTML tables.

(0) ShareShare
ReportReport
Posted on by 3

Hello,

I am facing a challenge in selecting a SQL query results into a batch of 50 rows per outlook email, for ex- If I have 200 sql rows , I need to send the results into a HTML table into 4 outlook emails (200/50) having 50 records each using Power Automate. How do I do that? Any expert please help. Thanks!

 

Categories:
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @prasadRvaidya 

     

    I stuck an array of 100 objects into a compose

     

    DamoBird365_0-1653422812320.png

     

    And came up with the following:

     

    DamoBird365_3-1653423432332.png

     

    A compose to define the batch size, one to calculate the No of Batches which will round down and then another to check if there is a remainder and add 1 to no of batches.  So if you had 100 records and batch size was 22, 100/22 = 4 remainder 12, so there would be a remainder and no of batches would be 5.

     

    div(length(outputs('ComposeMyArrayOf100Records')),outputs('ComposeBatchSize'))

     

    if(

        equals(mod(length(outputs('ComposeMyArrayOf100Records')),outputs('ComposeBatchSize')),0),

        outputs('ComposeCalcNoBatches'),

        add(outputs('ComposeCalcNoBatches'),1)

    )

     

    Then there is an apply to each that uses range from 0 and count based on number of batches, which creates an array 0,1,2,3,4 and we can use take and skip to skip a multiple of 0*batchsize i.e. 0, 1* batchsize i.e. 22, 2* batch size i.e. 44 etc and take the next 22 records.  This will loop 5 times and create 5 html tables and emails with the last email having just 12 records.

     

    take(skip(outputs('ComposeMyArrayOf100Records'), mul(item(), outputs('ComposeBatchSize'))), outputs('ComposeBatchSize'))

     

    DamoBird365_4-1653423536051.png


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

     

     

     

  • prasadRvaidya Profile Picture
    3 on at

    Hello Damien,

     

    Many many thanks! I will try it out and update you with the same. I also have another query. But first let me try your solution. Awesome ! and many thanks again. ! Stay safe take care !

     

    Regards,

    Prasad.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 298 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard