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 / Change color of button...
Power Apps
Answered

Change color of button for 24 hours

(0) ShareShare
ReportReport
Posted on by 39

Button OnSelect is.....

If(
Text(Last('Health Check').Date_Button_Pushed,"mm/dd/yyyy")=Text(Today(),"mm/dd/yyyy") &&
DateDiff(Last('Health Check').Date_Button_Pushed,Now(),TimeUnit.Hours)<=24,
Patch(
'Health Check',
Defaults('Health Check'),
{

ButtonColor: If(Last('Health Check').ButtonColor="Red","Green","Red"),
Date_Button_Pushed: Now(),
Health_Check: "1. New Part Set up - Daily",
Description: "Setup of all new parts the comes from the host based on dock i.d. & dimension ( Cognos Report)",
Category: "Daily"

}
),
Patch(
'Health Check',
Defaults('Health Check'),
{

ButtonColor: Last('Health Check').ButtonColor,
Date_Button_Pushed: Now(),
Health_Check: "1. New Part Set up - Daily",
Description: "Setup of all new parts the comes from the host based on dock i.d. & dimension ( Cognos Report)",
Category: "Daily"

}
)
)

 

 

------------------------------------------------------------------

 

Button Fill is..........

If(
IsEmpty(Last('Health Check')),
Color.Green,
If(
Text(Last('Health Check').Date_Button_Pushed,"mm/dd/yyyy")=Text(Today(),"mm/dd/yyyy") &&
DateDiff(Last('Health Check').Date_Button_Pushed,Now(),TimeUnit.Hours)<=24,
If(Last('Health Check').ButtonColor="Red", Color.Green, Color.Red),
If(Last('Health Check').ButtonColor="Red", Color.Red, Color.Green)

)
)

 

 

-----------------------------------------------------------------

 

I have multiple buttons with this same formula. As you may have already figured out, all of the buttons change color at the same time because I am using if(last.....

 

This formula is not letting me specify [ListName[.Column Name]

Example:  IF('Health Check'.Health_Check = "xyz".....)

 

Not sure what to do here.... Any help would be greatly appreciated!!! 🙂

 

Thank you!

Categories:
I have the same question (0)
  • WiZey Profile Picture
    3,023 Moderator on at

    Hello @frwewrfwef ,

     

    If you want to get a specific record based on some conditions... Have you tried "LookUp()"?

     

    https://learn.microsoft.com/fr-fr/power-platform/power-fx/reference/function-filter-lookup

  • frwewrfwef Profile Picture
    39 on at

    frwewrfwef_0-1679666531236.png

    I did try that before. Got an invalid argument type error. 

    the error said it expects boolean, number, text, optionsetvalue, untypedobject

  • frwewrfwef Profile Picture
    39 on at

    Hi @WiZey 

    frwewrfwef_1-1679666914852.png

     


     

    I did try that before. Got an invalid argument type error. 

    the error said it expects boolean, number, text, optionsetvalue, untypedobject

  • WiZey Profile Picture
    3,023 Moderator on at

    That's because "LookUp()" returns a record, which is a whole set of booleans, numbers, texts, optionsetvalues and untypedobject in a single item, depending on the structure of your list.

     

    What property of your record do you want to check? Its "Title"? Its "Created" date? Or a column you created yourself to store some data?

  • frwewrfwef Profile Picture
    39 on at

    Thanks for your reply again @WiZey 

    I want to check "a column I created myself"

  • WiZey Profile Picture
    3,023 Moderator on at

    Then use "LookUp()" like this:

    LookUp(...).column

     

  • frwewrfwef Profile Picture
    39 on at

    @WiZey 

    frwewrfwef_0-1679667394187.png

    Everything behind .Health_Check is highlighted in red. Said its expecting true/false. And theres a delegation warning 

  • WiZey Profile Picture
    3,023 Moderator on at

    The delegation warning can be ignored if your list will not exceed 2000 records.

     

    As for the error, just as it's saying it's expecting a boolean. I believe "Health_Check" is a text so maybe you want to test if it is equal to a string or if it's empty with "IsBlank()".

  • frwewrfwef Profile Picture
    39 on at

    @WiZey Thanks. Now I have this...

    frwewrfwef_0-1679667938073.png

     

    Health_Check is a text column with 11 different buttons so far. Each of these buttons have text that will be send to the sharepoint list once a day when pressed.

     

    Does the above formula look right? It's not doing what I was expecting 

  • WiZey Profile Picture
    3,023 Moderator on at

    Sorry, I think I misunderstood what you're trying to achieve with your app.

     

    If I'm not wrong, you're storing a history of records in a list, and the last record you're trying to extract is the most recent to check if its within 24 hours.

    And you also want to check if the last record has a specific status.

     

    I think this formula can help you:

    With({_lastRecord:Last('Health Check')}),
    If(
     _lastRecord.Health_Check = "1. ..." //Check if last record is the status you're looking for
     &&
     DateDiff(_lastRecord.Date_Button_Pushed, Now(), TimeUnit.Hours) <= 24,
     Color.Green,
     Color.Red
    )
    )

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard