cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jbloom
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: 

jbloom_2-1642782808088.png

 

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;', '"' 

        ) 

@RezaDorrani 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @jbloom ,

 

There are some syntax errors in your expression.

Please try this:

 

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

if( lessOrEquals( item()?['your column name'] , addDays(formatDateTime(utcNow(), 'yyyy-MM-dd'), 90, 'yyyy-MM-dd')),

concat('<font color= "Red">',item()?['your column name'],'</font>"') , concat('"<font color= "Green">',item()?['your column name'],'</font>"')))

 

 

Best Regards,

Wearsky

View solution in original post

2 REPLIES 2
ManishJain
Solution Sage
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

v-xiaochen-msft
Community Support
Community Support

Hi @jbloom ,

 

There are some syntax errors in your expression.

Please try this:

 

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

if( lessOrEquals( item()?['your column name'] , addDays(formatDateTime(utcNow(), 'yyyy-MM-dd'), 90, 'yyyy-MM-dd')),

concat('<font color= "Red">',item()?['your column name'],'</font>"') , concat('"<font color= "Green">',item()?['your column name'],'</font>"')))

 

 

Best Regards,

Wearsky

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (8,226)