cancel
Showing results for
Did you mean:
New Member

## Select and Change Text Color based on a Date value

The Requirements

Create an HTML report from selected data and change the text of the report based on a date value

For example

If the CAC expiration date is <= 90 days change the text of that item to red

If the CAC expiration date is > 90 days change the text of that item to green

Proposed Solution:

Expression

If (empty(item()?['CAC_x0020_EXPIRATION_X0020_DATE']), "",

if(item()?['CAC_x0020_EXPIRATION_X0020_DATE'] <= addDays(formatDateTime(utcNow(), 'yyyy-MM-dd'), 90, 'yyyy-MM-dd'),

"<font color= "Red">item()?['CAC_x0020_EXPIRATION_X0020_DATE']</font>" , "<font color= "Green">item()?['CAC_x0020_EXPIRATION_X0020_DATE']</font>"))

The issue:

It always says the expression is invalid

If the expression is taken I would then clean the HTML using a compose with this formula

replace(

replace(

replace(

replace(

replace (

body('Create_HTML_table'), '&lt;', '<'

),

'&gt;' , '>'

),

'&amp;', '&'

),

'&#39;', '"'

),

'&quot;', '"'

)

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

Hi @jbloom ,

There are some syntax errors in your expression.

``````If (empty(item()?['your column name']), '',

Best Regards,

Wearsky

3 REPLIES 3
Solution Sage

Hi @jbloom ,

Can you try using the alternate approach to calculate difference between two dates using below url :

https://sympmarc.com/2021/02/22/calculate-the-difference-between-two-dates-in-power-automate/

Thanks

Community Support

Hi @jbloom ,

There are some syntax errors in your expression.

``````If (empty(item()?['your column name']), '',

Best Regards,

Wearsky

Frequent Visitor

Hi

My input to the Create HTML is based on items expiring in 45 Days. I would like my output to reflect:

items expiring in 30 Days = Orange
items expiring in 20 Days = Red
Everything else outside this date range = Green

I have the following expression working great but only for items expiring 30 days (orange). How do I include additional script in this expression to capture items expiring 20 days (red)?  Not having much luck.

If (empty(item()?['EndDate']), '', if( lessOrEquals( item()?['EndDate'] , addDays(formatDateTime(utcNow(), 'yyyy-MM-dd'), 30, 'yyyy-MM-dd')),
concat('<span style="color:orange">', item()?['EndDate'], '</span>'),
concat('<span style="color:Green">', item()?['EndDate'])))

I really appreciate your help with this,

Thanks
Rob

Announcements

#### Take a short Community User Survey | Help us make your experience better!

To ensure that we are providing the best possible experience for Community members, we want to hear from you!    We value your feedback! As part of our commitment to enhancing your experience, we invite you to participate in a brief 15-question survey. Your insights will help us improve our services and better serve the community.    👉Community User Survey    Thank you for being an essential part of our community!    Power Platform Engagement Team

#### Tuesday Tip | How to Get Community Support

It's time for another Tuesday Tip, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.       This Week: All About Community Support Whether you're a seasoned community veteran or just getting started, you may need a bit of help from time to time! If you need to share feedback with the Community Engagement team about the community or are looking for ways we can assist you with user groups, events, or something else, Community Support is the place to start.   Community Support is part of every one of our communities, accessible to all our community members.   Within each community's Community Support page, you'll find three distinct areas, each with a different focus to help you when you need support from us most. Power Apps: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pa_community_support Power Automate: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpa_community_support Power Pages: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpp_community_support Copilot Studio: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pva_community-support   Community Support Form If you need more assistance, you can reach out to the Community Team via the Community support form. Choose the type of support you require and fill in the form accordingly. We will respond to you promptly.    Thank you for being an active part of our community. Your contributions make a difference!   Best Regards, The Community Management Team

#### Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!