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 / Trying to format cells...
Power Automate
Unanswered

Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

(0) ShareShare
ReportReport
Posted on by 380

I have the following Flow that runs a report of Field trips from Sharepoint lists and then emails an HTML table (see Flow-overview.PNG)

 

I am then trying to do 2 things which are not working:

I'm trying to use substitute to separate out people's names from a long string that looks like this: 

Joe Louis ; WARREN SMITH; Timothy Idesfelt ; Thomas Jones; * *

 

I would like it to look like: Joe Louis, WARREN SMITH, Timothy Idesfelt, Thomas Jones

My code looks like this and is not working at all:

<td>& " Substitute(Substitute(Substitute(@{items('Apply_to_each_2')?['officers']},";",""),"* *","")," "," ")" &</td>

 

The 2nd thing I am trying to achieve is to format the status cell with a red background and bold white font color IF the value of status is equal to Pending - this the code I have for that one:

<td & if equals item()?['@{items('Apply_to_each_2')?['status/Value']}'],'Pending',style=''background-color:red; color:white; font-weight:bold''','')>@{items('Apply_to_each_2')?['status/Value']}</td>    see Flow-detail.PNG as well

 

any assistance greatly appreciated thank you

flow-overview.PNG
flow-detail.PNG
Categories:
  • lbendlin Profile Picture
    8,726 Super User 2026 Season 1 on at

    you need to treat the HTML code as text.

     

    So instead of 

     

    <td>

     

    you need to use

     

    '<td>'

     

    etc.

  • bobgodin Profile Picture
    380 on at

    @lbendlin Hi - do you mean put quote characters like this:

    '<td>'& " Substitute(Substitute(Substitute(@{items('Apply_to_each_2')?['officers']},";",""),"* *","")," "," ")" &'</td>'

     

  • lbendlin Profile Picture
    8,726 Super User 2026 Season 1 on at

    sort of.  Note that PowerAutomate uses single quotes, not double quotes.

     

    more like this

     

    '<td>' &  Substitute(Substitute(@{items('Apply_to_each_2')?['officers']},';',''),'* *','') & '</td>'

  • bobgodin Profile Picture
    380 on at

    @lbendlin thanks for that

    when I try that I get the attached result in the HTML table - notice how the ' character is going into the next table definition.....I must have missed something...

    error-in-flow.PNG
  • lbendlin Profile Picture
    8,726 Super User 2026 Season 1 on at

    make sure to use the straight single quote, not any of the slanted accents.

  • bobgodin Profile Picture
    380 on at

    @lbendlin I only have the one single quote character on my keyboard - the one below the double quote character - that's the one I am using....

  • bobgodin Profile Picture
    380 on at

    Update: I have resolved the 1st problem I had by using Replace instead of Substitute (I found out that Substitute is not a supported function in Power Automate)

     

    For the benefit of others viewing this post I used a Compose action on the Officers field (which has multiple names in a string) and this code to replace the semi colons and asterisks with nothing:

    replace(replace(items('Apply_to_each_2')?['officers'],';',''),'* *','')
     
    I haven't had any responses regarding my 2nd problem (trying to format a cell font colour if the value was equal to Pending) although I studied a video that Reza Dorrani has where he changed the font colour based on the value in that cell - I copied the code and tried it but it failed saying I had only 1 condition in the If statement instead of 3
    My code for the If statement is in the 1st attachment and the 2nd attachment is a screenshot of the error I am getting.
     
    My If statement is: 
    if(equals(items('Apply_to_each_2')?['status/Value'],'Pending','Red','Black'))
    flow-code.png
    flow-html-error.png
  • bobgodin Profile Picture
    380 on at

    I have made some progress on the above problem and have managed to get the word "Pending" formatted in red in the Status column of my HTML table. However this is what I get:

    {"Status":"Approved"}

    [{"Status":"Pending"}]

    so, my syntax is a little wrong obviously

     

    can anyone help please @Reza @WarrenBelz

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