cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous5
Helper III
Helper III

HTML Table Conditional Format

Hi,

I'm using the Transform Data SQL action to produce a table of due dates for upcoming scheduled maintenance. These are based on time since a "last done date". The query is working well to calculate days left until the due date but as a final step I'd like to output this query to an HTML table.

After some other Googling, I've discovered how to insert borders and padding to make this HTML table look suitable for distribution using the Compose action.

As a final touch I would like to add some conditional formatting to the column which shows "days remaining" that will get a color based on how close it is to zero. For example 0-20 days gets red, 21-50 days orange, then yellow, then green, etc. Can this be expressed to Flow after the HTML table is created before pasting to an Outlook email?
6 REPLIES 6
Anonymous5
Helper III
Helper III

I've continued searching for this type of solution and the closest I've found is on this link:

https://alextofan.com/2019/02/14/flow-how-to-change-the-style-of-your-html-table-in-flow/

From my noobie point of view this of course seems pretty intimidating but the end result is just about what I'm looking for.

Anyone have any experience with this type of conditional HTML table output?

Hi @Anonymous5,

 

You need to change the condition of the original expression of the article, the structure is similar to the following:

if(and(greaterOrEquals(variables('Number'),0),lessOrEquals(variables('Number'),20)),variables('varStyle').rowStyleLowValues,variables('varStyle').rowStyleHighValues)

It means if the number is greater than or equals to 0 and less than or equals to 20, return a low value, or return high value.

And the value you can set in the variable shows in the article.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Lin,

How would this entry change for a 3-color arrangement? For me I’d like to have critical in red 0-20 days, marginal in yellow and all others just in white.

Hi @Anonymous5,

 

If you want to change three colors, you could use another if expression to instead of the third parameter of first if expression.

 

if(and(greaterOrEquals(variables('Number'),0),lessOrEquals(variables('Number'),20)),variables('varStyle').rowStyleLowValues,if(and(greater(variables('Number'),20),lessOrEquals(variables('Number'),40)),variables('varStyle').rowStyleMiddleValues,variables('varStyle').rowStyleHighValues))

 

If the Number is not greater than or equals to 0 and not less than or equals to 20, perform the second if expression.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sgr
Helper I
Helper I

@Anonymous5 , Is this been resolved? I am too looking for some what similar. Want to sent in email. 
Example i  have table with column name status.  If status is risk then red color, if safe then green color, if warning then yellow .

can you share screenshot of your solution..

 

exp.JPG
emailcol.JPG

Hi @Anonymous5, 

I had the same problem but I managed to solve it.

  • it would be best if you created a [SELECT]
  • Move all the Fields there.
  • for the field where you want to change the font color  ( <p style=" font color: add if condition ">name of the column</p>)
  • If ( equals ( the field name, ' value'),'color if','color elas').
  • then on the privouse ( create Html table) use the output of the SELECT, and change the columns to Automatic.
  • add a compos ( 
    replace(replace(replace(replace(replace(body('Name of your HTML table'), '&lt;''<'), '&gt;''>'), '&amp''&'), '&#39;''"'), '&quot;''"')
     
    in the send email add the compose [that has the style of the table] first then compose [has the replace expiration).
     
    hope that helps 
Ayedaanqalya_0-1659613535167.png

 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,127)