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 / TimeValue to Change La...
Power Apps
Answered

TimeValue to Change Label Color

(0) ShareShare
ReportReport
Posted on by 65

Hi

I have an App and I want a Label change color to yellow after 12 hours

and then changes to RED after 24 hours. What is the best TimeValue or DateDiff i can use for that? 

 

The below function isn't working for me

 

If(DateDiff(ThisItem.Date, Today(), Hours) > 24, OrangeRed, RGBA(0,0,0,0) &&
DateDiff(ThisItem.Date, Today(), Hours) > 12, Yellow, RGBA(0,0,0,0)

)

Categories:
  • Verified answer
    GarethPrisk Profile Picture
    2,828 on at

    You'll want to refactor your formula a bit.

    Effectively, as written, yours is currently doing the following

    • Check if the DateDiff > 24, then OrangeRed
    • Check if the RGBA(0,0,0,0) And DateDiff > 12, then Yellow (as you can see, this isn't valid)
    • Else RGBA(0,0,0,0)

    You can nest multiple checks in an If formula, but I think you have copied your else portion or accidentally assumed it needed an else in the middle.

    Try simplifying it as well, like this:

    With(
     {
     varDiff: DateDiff(
     ThisItem.Date,
     Today(),
     Hours
     )
     },
     If(
     varDiff > 24,
     RedOrange,
     varDiff > 12,
     Yellow,
     Transparent
     )
    )

    This allows you to read the formula in a much simpler manner. You define varDiff once, and then use it the formula below. The If statement is checking in order, so we just need the logic to match the possibilities. In your case, we'd want anything over 24 hours to be OrangeRed, else anything >12 hours to be Yellow, else Transparent.

  • evanscona Profile Picture
    65 on at

    Thanks - GarethPrisk 

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

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard