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 / Dynamically Create an ...
Power Automate
Unanswered

Dynamically Create an HTML Table with Child Table for Repeated Employee Names in Power Automate?

(0) ShareShare
ReportReport
Posted on by 4
I am working on a Power Automate flow where I need to dynamically create an HTML table based on employee data. The table should have a separate row for each employee. If the employee name is repeated, I want to append their data into the last row of the repeated employee instead of creating a new row each time. Additionally, after the last row for each employee, I need to insert a child table with dynamic values.

I am trying to create a output liek this
, 

the approach I have tied to create table


the output I have now,


No I want to insert the new child html below content after each employee row ,I mean last row 
Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,689 Super User 2026 Season 1 on at
    Instead of creating a custom HTML table, you use the "Create HTML table" action and modify its output.
     
    Here an example creating such a table from following example data:
    [
    {"Name":"Jim", "Value0": 0, "Value1": 1},
    {"Name":"John", "Value0": 0, "Value1": 0},
    {"Name":"Jim", "Value0": 10, "Value1": 11},
    {"Name":"Jane", "Value0": 0, "Value1": 1},
    {"Name":"Jane", "Value0": 10, "Value1": 11},
    {"Name":"Jim", "Value0": 20, "Value1": 21}
    ]
     
     
    From the array (sorted by Name) in a Compose, Create HTML table
     
    Initialize variable with this HTML
     
    Apply to each distinct Name
    union(
    	xpath(
    		xml(json(concat('{"Root":{"Item":',outputs('Compose'),'}}'))),
    		'//Item/Name/text()'
    	),
    	json('[]')
    )
     
    In a Compose 2, find the first occurence of the td with the Name and add a rowspan to it. The value is the count of this Name in the data array.
    Also add a CSS class to the tr.
    remove the td with this Name from the rest of the table.
    concat(
    	replace(
    		slice(
    			variables('htmlTable'),
    			0,
    			nthIndexOf(
    					variables('htmlTable'),
    					concat('<tr><td>',items('Apply_to_each'),'</td>'),
    					2
    				)
    		),
    		concat('<tr><td>',items('Apply_to_each'),'</td>'),
    		concat('<tr class="namerow"><td rowspan="',
    			length(
    				xpath(
    					xml(json(concat('{"Root":{"Item":',outputs('Compose'),'}}'))),
    					concat('//Item[Name="',items('Apply_to_each'),'"]')
    				)
    			),
    		'">',items('Apply_to_each'),'</td>')
    	),
    	replace(
    		slice(
    			variables('htmlTable'),
    			nthIndexOf(
    				variables('htmlTable'),
    				concat('<tr><td>',items('Apply_to_each'),'</td>'),
    				2
    			)
    		),
    		concat('<tr><td>',items('Apply_to_each'),'</td>'),
    		'<tr>'
    	)
    )
    Use Set variable store the output of Compose 2
     
    After the loop, add some styles to the HTML in Compose 3
     
     
     
    The resulting table needs some additional styles to look great ;)
     
  • Chriddle Profile Picture
    8,689 Super User 2026 Season 1 on at
    A similar approach with the same result as below (but a bit more compact)
     
    Create HTML table
    sort(outputs('Compose'), 'Name')
    Select
    From:
    range(0, length(split(body('Create_HTML_table'), '<tr>')))
     
     
    Map:
    if(
    	less(item(), 2),
    	split(body('Create_HTML_table'), '<tr>')[item()],
    	if(
    		startswith(
    			split(body('Create_HTML_table'), '<tr>')[sub(item(), 1)],
    			slice(
    				split(body('Create_HTML_table'), '<tr>')[item()],
    				0,
    				add(
    					indexOf(
    						split(body('Create_HTML_table'), '<tr>')[item()],
    						'</td>'
    					),
    					5
    				)
    			)
    		),
    		slice(
    			split(body('Create_HTML_table'), '<tr>')[item()],
    			add(
    				indexOf(
    					split(body('Create_HTML_table'), '<tr>')[item()],
    					'</td>'
    				),
    				5
    			)
    		),
    		concat(
    			'<td rowspan="',
    			
    			length(
    				xpath(
    					xml(json(concat('{"Root":{"Item":',outputs('Compose'),'}}'))),
    					concat('//Item[Name="',
    					slice(
    						split(body('Create_HTML_table'), '<tr>')[item()],
    						4,
    						indexOf(
    							split(body('Create_HTML_table'), '<tr>')[item()],
    							'</td>'
    						)
    					),
    					'"]')
    				)
    			),
    			
    			'">',
    			slice(
    				split(body('Create_HTML_table'), '<tr>')[item()],
    				4
    			)
    		)
    	)
    )
     
    Compose 4
    replace(
    	join(body('Select'), '<tr>'),
    	'<tr><td rowspan',
    	'<tr class="namerow"><td rowspan'
    )
     
  • POWERCOIN_USER Profile Picture
    4 on at
    Thanks for your reply.I see this output 
    The resulting table needs some additional styles to look great ;)
     
     
    I got same out put but My request is here to insert this child table mentioend below in each Name's under ..Like Jane records after 10,11 I need this child table and After jim's row 20,21 i eed to this child table value and I need to check this Name has child records based on the date And I need to insert it.

  • Chriddle Profile Picture
    8,689 Super User 2026 Season 1 on at
    If you preffer to create the HTML yourself, you can do something like this:
     
    Select 2
    From:
    range(0, length(sort(outputs('Compose'), 'Name')))
    Map:
    if(
    	or(
    		equals(item(), 0),
    		not(
    			equals(
    				sort(outputs('Compose'), 'Name')[sub(item(), 1)].Name,
    				sort(outputs('Compose'), 'Name')[item()].Name
    			)
    		)
    	),
    	concat(
    		'<tr class="namerow"><td rowspan="',
    		length(
    			xpath(
    				xml(json(concat('{"Root":{"Item":',outputs('Compose'),'}}'))),
    				concat('//Item[Name="',sort(outputs('Compose'), 'Name')[item()].Name,'"]')
    			)
    		),
    		'">',
    		sort(outputs('Compose'), 'Name')[item()].Name,
    		'</td><td>',
    		sort(outputs('Compose'), 'Name')[item()].Value0,
    		'</td><td>',
    		sort(outputs('Compose'), 'Name')[item()].Value1,
    		'</td></tr>'
    	),
    	concat(
    		'<tr><td>',
    		sort(outputs('Compose'), 'Name')[item()].Value0,
    		'</td><td>',
    		sort(outputs('Compose'), 'Name')[item()].Value1,
    		'</td></tr>'
    	)
    )
    Compose 2
    join(body('Select_2'), '')
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 976

#2
Valantis Profile Picture

Valantis 863

#3
Haque Profile Picture

Haque 547

Last 30 days Overall leaderboard