
Announcements
Hi Guys,
I am currently developing and App that is suposed to highlight and show some boxes according to the current time.
For instance, if it is 12:30, Boxes number 2 and 3 must turn Yellow up to 13:00 when they turn Red up to 13:30 when they disappear.
The logic behind it seems easy except for the part that I am not being able to do the "Math". Is it possible ?
Best Regards
If I understand your problem correctly, you want to have two boxes that will appear between 12:30 and 13:00 (as yellow), 13:00 and 13:30 (as red) and not show up in other times of the day... If this is the case, then you can use an expression like the following in the Fill and/or Color property of your control:
If(
Hour(currentTime) = 12 And Minute(currentTime) >= 30; Color.Yellow;
Hour(currentTime) = 13 And Minute(currentTime) < 30; Color.Red;
Color.Transparent)
Where 'currentTime' is a variable that you can update based on a timer. For example, if you add a timer to your screen, and set the properties below with the following values:
Duration: 10000
Repeat: true
AutoStart: true
AutoPause: false
OnTimerEnd: Set(currentTime; Now())
Then when your app is in the screen where your boxes are shown, the value of 'currentTime' will be updated every 10 seconds with the current time, and that will change the color of the boxes if the time crosses one of the thresholds.
The attached app shows this logic. I've also added a button where you can "override" the current time for a while (until the timer is triggered again) so you can test your logic in other times of the day. To open it, save it locally, then go to https://create.powerapps.com, select Open, Browse, then find the file that you saved before.
Hope this helps!