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 Apps / Correction of code for...
Power Apps
Answered

Correction of code for With() along if function

(0) ShareShare
ReportReport
Posted on by 2

I want to fill the color of rectangle based on the below condition:

 

The field on which the condition to be based is      SearchResultGallery_1.Selected.DelDate

If the expiry is going to come within 15 days then yellow color

If already  expired based on today date then red color
 
so I tried to write the below code but getting error of invalid :
 
With({
    wSvcRemind1:DateAdd(SearchResultGallery_1.Selected.DelDate,15,TimeUnit.Days)}
    If(wSvcRemind1<=Today(),Color.Yellow,
    If(SearchResultGallery_1.Selected.DelDate<=Today(),Color.Red,
    Color.Blue)
    )
)
)
 
MIA27_0-1712476240275.png

 

Please guide 

 
 
 
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,242 Most Valuable Professional on at

    Hi @MIA27 ,

    You were missing a comma and can also get rid of some brackets

    With(
     {
     wSvcRemind1:
     DateAdd(
     SearchResultGallery_1.Selected.DelDate,
     15,
     TimeUnit.Days
     )
     },
     If(
     wSvcRemind1 <= Today(),
     Color.Yellow,
     SearchResultGallery_1.Selected.DelDate <= Today(),
     Color.Red,
     Color.Blue
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard