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 / How do I write an expr...
Power Automate
Answered

How do I write an expression to add conditional formatting to a HTML table?

(0) ShareShare
ReportReport
Posted on by 67

I'm making a flow that takes a SharePoint list and then makes it into a word document. The list column names are title, content, section, and subsection.

 

The format output is like this: 

Natso_1-1689199306990.png

 

The flow works, but I need to add headings (such as h1 and h2) to each of the sections for readability. For example, I need the value of "introduction" in the image above to have a h1 header.  What is the expression I would type to make the column of Title have a h1 heading if the subSection value equals zero? I tried typing this code into the create HTML table step in the value box (expression field), but it was invalid:


if(equals(item()?['SubSection'],0),concat('<h1>', item()?['Title'], '</h1>'), <ifFalse>)

 

I would also like to have the expression give the title a h2 header if the SubSection's value is not zero. I didn't know what to type for that in the ifFalse area.

 

This is the flow:

 

Natso_0-1689199085909.png

The reason I need the headers is because the table is eventually going to be converted to text in word. It's harder for people to read the document without the headers. I will then make a table of contents using the headers.

 

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi

     

    Try

    item()?['Title']

    item()?['Content']

     

  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi @Natso 

     

    You don't need the Select action step here. Get Items already returning the results in an array format. So you can directly pass the value under the Create HTML action step.

     

    Here it is

     

    image.png

     

    Here the expression I used is

     

    item()?['Title']
     
    Thanks
  • Natso Profile Picture
    67 on at

    Thanks for replying. You're right; the select step is redundant. Your answer gives me the value in the column.

     

    However, I'm still not able to apply conditional styling to table columns. I want to apply a <h1> to the title column if the SubHeading value is zero, and apply a <h2> to the title if the SubHeading value is anything other than zero. I tried following the steps in this blog, but I'm using a different if expression, so it doesn't work for me. Do you have advice for what I can do?

  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi @Natso 

     

    This is one the best blogs about styling. Please have a look.

     

    Power Automate HTML Table Styling – Ryan Maclean (ryanmaclean365.com)

     

    Thanks

  • Verified answer
    Natso Profile Picture
    67 on at

    I ended up just manually creating a new SharePoint column with rich text. Then I went into classic view to add the headings.

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 419

#2
Vish WR Profile Picture

Vish WR 314

#3
David_MA Profile Picture

David_MA 260 Super User 2026 Season 1

Last 30 days Overall leaderboard