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 / Gallery colour dependi...
Power Apps
Answered

Gallery colour depending on date

(0) ShareShare
ReportReport
Posted on by 181

Hi all.

 

Within my app I have a gallery for employee profiles. Within the profile sharepoint list I have 3 date boxes, 

 

Rota Start date

Rota End date

Shifts completed date

 

so as a prompt to complete the rota in time I need the the gallery colours to highlight in the following:

 

If Rota start date = 3 weeks from now, colour green

if Rota Start date = 2 weeks from now, colour yellow

if Rota Start date = 1 week from now, colour red,

 

If Shifts Completed date is = to Rota Start Date, no fill colour. 

thanks

Categories:
I have the same question (0)
  • Verified answer
    v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @Angry_Sys_Admin ,

     

    Do you want to set the item to red when the Rota Start date is within the next week, yellow when it is within the second week, and green when it is after the second week?

     

    Maybe you could try the following formula:

    If(ThisItem.'Rota start date'=ThisItem.'Shifts completed date',RGBA(0, 0, 0, 0),
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),27)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),21),Green,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),20)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),14),Yellow,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),13)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),7),Red,RGBA(0, 0, 0, 0))))
    )

    vyujincuimsft_0-1664433556227.png

     

     

    Best Regards,

    Charlie Choi

  • Angry_Sys_Admin Profile Picture
    181 on at

    @v-yujincui-msft This solution worked perfectly, thank you very much.

  • Angry_Sys_Admin Profile Picture
    181 on at

    @v-yujincui-msft 

     

    Just thought, I could do with adding a flag for 5 weeks prior to rote start.  I added the following code but this didn't work, what am I getting wrong here?

     

    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),34)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),35),LightBlue,

     

    Many thanks for your help

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @Angry_Sys_Admin ,

     

    Is this what you need?

    If(ThisItem.'Rota start date'=ThisItem.'Shifts completed date',RGBA(0, 0, 0, 0),
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),27)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),21),Green,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),20)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),14),Yellow,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),13)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),7),Red,If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),41)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),35),LightBlue))))
    )
    

    vyujincuimsft_0-1664519634152.png

     

     

    Best Regards,

    Charlie Choi

  • Angry_Sys_Admin Profile Picture
    181 on at

    @v-yujincui-msft @Yes this is what I need. Im trying to understand how the code works. On the image attached, I know the numbers circled in Red is the day count from current date, but what do the numbers circled in Green represent?

    Image.jpg

     

    for my own sanity, Would a 4 week colour flag in say, grey, would this code be correct

     

    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),35)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),28),Grey

     

     

    Many thanks for your support

     


    @v-yujincui-msft wrote:

    Hi @Angry_Sys_Admin ,

     

    Is this what you need?

     

     

    If(ThisItem.'Rota start date'=ThisItem.'Shifts completed date',RGBA(0, 0, 0, 0),
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),27)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),21),Green,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),20)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),14),Yellow,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),13)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),7),Red,If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),41)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),35),LightBlue))))
    )

     

     

    vyujincuimsft_0-1664519634152.png

     

     

    Best Regards,

    Charlie Choi



    @v-yujincui-msft wrote:

    Hi @Angry_Sys_Admin ,

     

    Is this what you need?

     

     

    If(ThisItem.'Rota start date'=ThisItem.'Shifts completed date',RGBA(0, 0, 0, 0),
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),27)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),21),Green,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),20)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),14),Yellow,
    If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),13)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),7),Red,If(ThisItem.'Rota start date'<=DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),41)&&ThisItem.'Rota start date'>DateAdd(DateAdd(Today(),-Sum(Weekday(Today(),StartOfWeek.Monday),-1)),35),LightBlue))))
    )

     

     

    vyujincuimsft_0-1664519634152.png

     

     

    Best Regards,

    Charlie Choi


     

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