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 / Filling the icon 1 tim...
Power Apps
Answered

Filling the icon 1 time a week?

(0) ShareShare
ReportReport
Posted on by 361

hey guys,

I need to make a condition for the fill of this icon. I need it to be orange every Monday at 7 am, however, it will paint the fill green if the date of the label9_2.text (comes from another base) is greater than the date on which the icon was painted orange ( Monday, 7 A.M.)

Joaoandrebs_0-1688404511489.pnglabel 9_2.text in red!

 

Ex: 07/03/23 - Monday - 7 AM = orange color
label9_2 = 03/07/23 - Monday - 10 AM = green color
and the next orange color will be on 03/10/23 at 7 am!

 

Grateful!!

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Joaoandrebs,

     

    Please give the code below a try in the Fill property:

    If(
     //On Monday & time is exactly 7am
     Weekday(
     Today(),
     StartOfWeek.Monday
     ) = 1 && Now() = Time(
     7,
     0,
     0
     ),
     If(
     //If label time is less than 7am
     DateTimeValue(Label9_2.Text) < Time(
     7,
     0,
     0
     ),
     //Show orange
     Color.Orange
     ),
     //In all other cases show green
     Color.Green
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Joaoandrebs Profile Picture
    361 on at

    @LaurensM firstly thanks for the answer bro,


    and I believe that your code is correct, but I believe that the detail is that the times change because I'm from the pt-br zone and not en-us (?). here our schedule does not have A.M or P.M and I think it is impacting in some way... look:

     

    Joaoandrebs_0-1688434551944.png

    Joaoandrebs_1-1688434626364.png

    now, this is stranger:

    Joaoandrebs_2-1688434818682.png

     

    to me it seems to be this... I don't know what to say about it?

  • Joaoandrebs Profile Picture
    361 on at

    @LaurensM im verificating, look this 😐🤔

    Joaoandrebs_0-1688473172669.png

     

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Joaoandrebs,

     

    I clearly made a mistake, I see. Please use the following adjustment:

    If(
     //On Monday & time is exactly 7am
     Weekday(
     Today(),
     StartOfWeek.Monday
     ) = 1 && Now() = Today() + Time(
     7,
     0,
     0
     ),
     If(
     //If label time is less than 7am
     DateTimeValue(Label9_2.Text, "pt-BR") < Today() + Time(
     7,
     0,
     0
     ),
     //Show orange
     Color.Orange
     ),
     //In all other cases show green
     Color.Green
    )

     

    As a note: Weekday(Today(), StartOfWeek.Monday) returns a number depending on the weekday. In this case, Monday will have the value 1.

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Joaoandrebs Profile Picture
    361 on at

    @LaurensM 

     

    Joaoandrebs_0-1688475014290.png

    I'm testing through the current day (Wednesday), and by the launch I made yesterday (Tuesday), it should appear orange, but it only appears green..

    What I find strange is that "Time" is returning the date 1/1/1970.

  • Joaoandrebs Profile Picture
    361 on at

    @LaurensM 

     

    Joaoandrebs_1-1688475302494.png

    but this one is correct...

     

    Joaoandrebs_2-1688475315899.png

     

     

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Joaoandrebs,

     

    I made some additional adjustments and removed the nested if() statements. With the code below we will only display an orange color when the current time is after Monday 7AM (of this week) & the label is before Monday (of this week) 7AM.

    With(
     //Temp save current Monday 7am value
     {wCurrentMondayMorning:DateAdd(Today(),-Weekday(Today(),StartOfWeek.MondayZero),TimeUnit.Days)+Time(7,0,0)},
     If(
     Now() >= wCurrentMondayMorning && 
     DateTimeValue(Label9_2.Text,"pt-BR") < wCurrentMondayMorning,
     //Monday, currently 7AM or later & the label date is before Monday of this week 7AM - show Orange
     Color.Orange,
     //In all other cases show green
     Color.Green
     )
    )

    The code above will only show green when the (1) the label date is after the current Monday 7AM or (2) it is currently Monday before 7AM.

     

    I hope this helps!

  • Joaoandrebs Profile Picture
    361 on at

    @LaurensM 

    I believe we are on the way! however, when checking, I inserted a button and created an updateContext to see what the return was, and on Monday it was OK! however on Tuesday, the only thing I changed in the formula was StartOfWeek.Monday to StartOfWeek.Tuesday, and it produced the same value (?) I didn't quite understand!

    UpdateContext({wCurrentMondayMorning1:DateAdd(Today(); -Weekday(Today();StartOfWeek.Tuesday);TimeUnit.Days)+Time(7;0;0)})

    But APPARENTLY it's working, so I'm not likely to check.

     

    Joaoandrebs_0-1688480415961.png

     

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Joaoandrebs ,

     

    I understand the confusion surrounding the variables. My code uses StartOfWeek.MondayZero: Monday returns 0, Tuesday 1, Wednesday 2... We use these numbers to 'subtract' the difference between today and this week's Monday in order to get Monday's date.

     

    Using StartOfWeek.Tuesday will look quite similar with one exception. Tuesday will return 1, Wednesday 2... However, Monday will return 7

  • Joaoandrebs Profile Picture
    361 on at

    @LaurensM 

    hello laurens! all very well?

     

    I inserted your code in another problem I have,

     

    I have a system that changes the fill of an icon to green and yellow in 3 conditions, daily, weekly and monthly. This condition applies from records saved in a list, which are answered in a form, which some of these records are monthly, daily and weekly.

     

    Joaoandrebs_0-1688577159265.png

    What i have: 

    Diary turns yellow 7:00 A.M every day
    Weekly turn yellow every Monday at 7:00      ----    ok!
    Monthly turn yellow every 1st at 7:00 of every month

    I believe I have only one detail to modify, but I haven't found a way yet

    Switch(
     ThisItem.Frequencia;
     "Semanal"; With(
     //Temp save current Monday 7am value
     {wCurrentWeekly:DateAdd(Today(); -Weekday(Today();StartOfWeek.MondayZero);TimeUnit.Days)+Time(7;0;0)};
     If(
     Now() >= wCurrentWeekly && 
     DateTimeValue(Label9.Text;"pt-BR") < wCurrentWeekly;
     //Monday, currently 7AM or later & the label date is before Monday of this week 7AM - show Orange
     Color.Orange;
     //In all other cases show green
     Color.Green
     )
    );
     "Diario"....
     "Mensal"...

     

    I've tried numerous solutions but none of them work for my tests 😞

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard