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 / Adding background colo...
Power Automate
Answered

Adding background color to HTML table cell based on condition

(0) ShareShare
ReportReport
Posted on by 52

I created a table in an email using HTML code (because it worked better than creating the table with Create HTML Table).  Here is the part of the HTML:

 

 SMiller3_0-1693836379967.png

 

that produces this result below the column headers:

 

Entry

Previous

UPDATE

Quantity

1

2

 

I need to change the background color of the Quantity UPDATE cell when the quantity changes from previous.

 

When I create the following formula in a compose and place its output right before output for the update column, it just puts the word yellow before the 2.  

 

if(outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/ColumnHasChanged/Quantity'],'yellow',)
 
How should the expression look to achieve desired result and where exactly should the output be placed in the HTML?
 
TYIA
Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,953 Most Valuable Professional on at

    hi @SMiller3  here is an example about using if as expression

    If (true/false,if true,if false)

    As you can see you need to provide first a true or false value. How can you get that? maybe using another expression like empty(). For example: If Column is empty then true, if no then false.

     

    If(empty(Column),'ShowBlackColor', ShowYellow)

     

    As you are working on HTML I'll replace the css code with my expression.

     

    so you can try if(true/false,'style='color:black'',style='color:yellow')

  • SMiller3 Profile Picture
    52 on at

    I think I have the formula with the condition, but am having trouble placing it in the html.

     

    I made a simpler expression just to get the cell to turn yellow:

     

    style=\"background-color:yellow;

     

    and put it in the html as below:

     

    SMiller3_0-1694621834120.png

    This is the result:

    SMiller3_1-1694621891119.png

    If placed right before dynamic content, I get this:

    SMiller3_2-1694621956223.png

    And when I placed the style color expression between <td and width=252, I get this:

     

    SMiller3_3-1694622175888.png

     

    Does anyone know where to put the expression so it will look like this?

    SMiller3_4-1694622304743.png

     

     

  • Verified answer
    SMiller3 Profile Picture
    52 on at

    For anyone that's interested, I was able to figure this out.

     

    Based on the original example, I created a compose action with if expression:

     

    SMiller3_0-1694713120619.png

     

    In the body of the email, I inserted the outputs from above right before <p class=MsoNormal following the <td for the relevant cell:

     

    SMiller3_1-1694713234700.png

     

    Notice (highlighted in yellow) that the space between <p and class needs to be removed and another </p> needs to be added (its initial<p is in the compose action).

     

    The result is:

    SMiller3_2-1694713547061.png

     

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 784

#2
Valantis Profile Picture

Valantis 581

#3
Haque Profile Picture

Haque 545

Last 30 days Overall leaderboard