Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 4mmE+d7dz4vKthA5tCu52D
Power Automate - General Discussion
Unanswered

How to Create a Repeating Table in a Word Template with Grouped Rows?

Like (0) ShareShare
ReportReport
Posted on 26 Dec 2024 01:40:19 by 16

I have a table in Word with multiple rows, where each item should be represented as a separate row. For items with multiple associated rows, they need to be grouped together. For example, in my table (screenshot attached), I have classifications like "Air Track Operator" and "Air Track Operator (Heavy & Highway)" with multiple rows for different dates. I want to:

  1. Create a repeating table in a Word template to handle this structure.
  2. Ensure that rows for the same classification are grouped together.
  3. Be able to update or add new rows programmatically later.

What’s the best way to set up this repeating table in Word? Can I use content controls or other features? I’d also like guidance on how to bind data dynamically if possible.

Any help or suggestions would be appreciated!

  • Mark Nanneman Profile Picture
    989 Super User 2025 Season 1 on 31 Dec 2024 at 20:23:15
    How to Create a Repeating Table in a Word Template with Grouped Rows?
    Hello Gowtham,

    Unfortunately the Word Template action in Power Automate can't handle nested tables / grouped arrays.  There are a few ways to fake it using the Word Template, and you can also opt to create an HTML file with true nested tables and convert that to PDF.
     


    Method One: Fake a Grouped By Array in Power Automate and Populate a Word Template:

    I don't know how your input data array is structured, but I'll show you an example assuming you have a flat array.  I took your screenshot and had an AI OCR it and put it into a JSON array.  I had it just repeat the "Classification" for each row in the nested table, so for example there's a bunch of "Air Track Operator" items in the array.

     
    I put this array into a compose called "Array".  But it could be the output of a select action, or whatever action is returning your list in your flow.  I also make an array variable called "vFinalArray" which is what we will send to the Word Template. 

    Then add an apply to each and have it loop through your original array.

    The idea is the loop checks to see if the current "Classification" value of the original array (the property value you don't want to repeat to give the appearance of a grouped table/collection) is in the vFinalArray.  If it's not there, we appened it to the array.  If it is there we appened an object that just has a blank for the "Classification" but has values for the nested table's columns.



    I also made a compose to add the multiple rows we see for some of your classifications.  I just called them "Subtitle" and "Note"


    Here's a filter action in the loop, which filters vFinalArray to check if its item()?['Classification'] contains the current object's item()?['Classification'] value.  Has it been added yet?

    The condition then checks the count of the items returned by the filter using a Length() function.  If it's zero i have it append a couple blank objects to the array then a new object with the classification value.


    Adding a blank row for spacing:

    Also you could add some dashes if you like:

    Then add a new row with the classification + subtitle + note block:

    If the filter does return a row with the classification, then the conditional false branch will just add the details from the "nested" row without anything for the classification property, giving the illusion of a nested table row in the final output.

    This all goes into the word template:


    And in the end we get something like the following (using a very simple word template I threw together in a minute).

    The formatting isn't perfect, especially if your classification text is multi-lined, but if you can keep your "Grouped by" name column to one line it will look pretty much like a nested table.

    Method Tow: Make a True Nested / Grouped Table in HTML and Convert to PDF 


    Another option you have is to loop through your data array and compose html rows, and append those to a string variable.  Then save that as a  .html file in one drive, use the one drive "convert" action to convert the html to pdf.

    The flow would look something like the following in the end.  An upside here is you can use some CSS styling to change your table's appearance.

    Here's a version I did in a couple minutes using an AI assistant to help with the CSS styling.





     
    The HTML takes a bit more work, but it's far more flexible and it's a true nested table.  You can play with the css to adjust your borders as you like.

  • Gowtham_TheCute Profile Picture
    16 on 27 Dec 2024 at 23:32:30
    How to Create a Repeating Table in a Word Template with Grouped Rows?
    @Mark Nanneman  Thanks for your effort..

    The answer you provided seems to focus on direct repeated control, where only one item is repeated per service (e.g., Service A, Service B). However, if you review my question, Service A contains multiple items based on different dates, and Service B might have repeated items or sometimes none at all. Essentially, this involves a set of services.

    After each service set, I need to insert a child table in a repeated format. You can refer to the 'Apprentice' table in my question, which serves as a repeated child table.

    Could you confirm if this functionality is achievable in the Word template?

  • Mark Nanneman Profile Picture
    989 Super User 2025 Season 1 on 27 Dec 2024 at 21:01:51
    How to Create a Repeating Table in a Word Template with Grouped Rows?
    Hello Gowtham,

    I've used repeating rows in Word templates in the past for things like Paystubs, Invoices, Orders and even inspection reports in the past.  It's doable and sometimes the best choice.  It's a bit of a pain to setup the controls in word and then do the mapping in power automate but not too bad once you do it a few times.  

    (That said, the next time I have to, I think I'm going to try just building an HTML document and converting it to PDF--if it's even necessary to do it in PDF).

    Here's how to do it in Word.
     


    1. You need to enable Developer

     

    2. add a table (two rows only). 

     

    (And FYI--you can do these steps multiple times--with different tables with repeating rows that start on different sections of your document, etc.)

    Fill in your headers.  Setup your table design/formatting how you like

    e.g.
     

    3. add a plain text control from the developer tab for each cell/column you want dynamically populated

     

    I like to type in the name of the header in each one, makes it easier to map in power automate

    4. The key part--select the whole row and add a repeating control

     



    5. Map in Power Automate

     
    - add a populate a microsoft word template action:



    6. Find and prepare a template for your repeating control


    Find your repeating control (it'll have an "Add new item") button.  Click that.

    type some placeholder values in then toggle to view the JSON array (click this icon:)

    7.  Use this array to help map your data in a Select operation. 

     
    Your select will draw from your datasource (Sharepoint list, Excel Sheet, Dataverse table, whatever).  You can also do some math here, for exmample if you have a "total" column that multiples or sums two other columns.


    Then you can put the Select's output into the repeating control on the word template, and add some actions to save and convert the .docx to a PDF.

    Here's how it runs on some sample data:


    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  |

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - General Discussion

#1
rpersad Profile Picture

rpersad 16

#2
David_MA Profile Picture

David_MA 10 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 8 Super User 2025 Season 1

Overall leaderboard
Loading started
Loading complete