web
You’re offline. This is a read only version of the page.
close
Skip to main content
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:
I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Dividing a Batch of 200 SQL Result Rows and sending 50 Result Rows each into 4 Outlook emails containing records into HTML tables.

    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
    Re: Dividing a Batch of 200 SQL Result Rows and sending 50 Result Rows each into 4 Outlook emails containing records into HTML tables.

    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard