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 / Set color if any item ...
Power Apps
Answered

Set color if any item in gallery has a match with a time value

(0) ShareShare
ReportReport
Posted on by 603

Hi all,

 

I'm try to set a rectangle color to purple if I have any match in my gallery that has the date time value with a date in my variable and with the time 09:00 OR earlier.

 

I was thinking to do it with a collection and count the number of items in the collection, but that's only working if the start time is exactly 09:00.

 

For your information, I'm working with dataverse. I save the date in a variable: var_DateWednesday.  My gallery, named Wednesday has a couple of items. In my rectangle at the fill property, I add the folow formula:

The startdate field is a date/time value in dataverse.

If(CountRows(Filter(Wednesday.AllItems,'Startdate (startdate_dateonly)'=var_DateWednesday And Text('Startdate (startdate)',"hh:mm") = "09:00"))>=1,Purple, Blue)

What I want is the follow: 

I want also set the color purple if the time in startdate is earlier than 09:00. (for example: 06:00)

How can I do that? I try <= but that would not work because I transformed the startdate to a Text value.

 

Any suggestion will be welcome!

 

Thanks in advance.

Categories:
I have the same question (0)
  • FraserCDear Profile Picture
    17 on at

    Hi there Dennis,

     

    Without unpicking what what you have done already.  

     

    You could extract out the first two characters Left(var,2) and then convert it back to a number, then do your less than?

     

    Just a thought?

  • dennisb88 Profile Picture
    603 on at

    Hi @FraserCDear , 

    Thank you for your reply.

    I'm not realy understand how/what you mean.

     

    If I try to putt the 09 in to a variable it won't work.

     

    Can you give an example what you mean/ how I need to change my formula?

     

    Thanks in advance.

     

  • Verified answer
    rsaikrishna Profile Picture
    3,703 on at

    @dennisb88 

     

    Instead of using string functions, Date has many date specific functions.

     

    For Example: To get an hour form a date function, you can use Hour(<date and time value>)

     

    Reference: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datetime-parts

     

    Regards

    Krishna Rachakonda

    If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.
  • dennisb88 Profile Picture
    603 on at

    Hi @rsaikrishna ,

    Thank you! 

    I changed it to: 

    If(CountRows(Filter(Wednesday.AllItems,'Startdate (startdate_dateonly)'=var_DateWednesday And Hour('Startdate (startdate)') <= 9))>=1,Purple, Blue)

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

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard