Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Color changing items in dropdown by date.

Posted on by 223

Hello,

 

So I'm not even sure this is possible but I figure I would see if anyone has any ideas. I want to see if I can have items gradually change colors by the date. They would start out green and by mid week they would be yellow and after 7 days would be red. Also I would be great if I could add a progress\deterioration Color bar showing the color change. 

 

I have a dropdown linked to a sheet on OneDrive with 12 machines in it. These machines need to be cleaned at least once a week, but we have several people across different shifts. I want to make it easy for people to see which machines have been recently cleaned. weather its in the dropdown list or I could add icons or labels that represent the machines on the screen. I pull the items in the dropdown from one (Table "VH_Etcher_Info") with (Field: "Name:") and I Submit the record to another (table "Etcher_Cleaning_Sheet") with (Field: "Machine Name").

 

Let me know if you need more info or screen shots on the app.

Categories:
  • JR-BejeweledOne Profile Picture
    JR-BejeweledOne 5,825 on at
    Re: Color changing items in dropdown by date.

    This is what I like best about our community here.  Not that someone else necessarily solves an issue for you, although that does happen, but that it more often guides us take someones advice and thoughts and use them to make the solution that works perfectly for us. 

     

    I am glad you got it working!

  • Verified answer
    Chrisguff12 Profile Picture
    Chrisguff12 223 on at
    Re: Color changing items in dropdown by date.

    JR-BejeweledOne thanks again for taking the time to try and help me. I was able to get the get the color change by date using your help and this other thread. I just hade to expand a little to get more color changes.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Change-color-of-text-displayed-in-gallery-based-on-dates-overdue/m-p/600348#M188748

     

    I made a gallery with the machines and changing there color property of the machines and linking the to date I used this formula:

     

    If(DateDiff(ThisItem.'Last Time Cleaned',Today())<=1,Color.DarkGreen,DateDiff(ThisItem.'Last Time Cleaned',Today())<=2&&DateDiff(ThisItem.'Last Time Cleaned',Today())<=3,Color.Green,DateDiff(ThisItem.'Last Time Cleaned',Today())<=4&&DateDiff(ThisItem.'Last Time Cleaned',Today())<=5,Color.Yellow,DateDiff(ThisItem.'Last Time Cleaned',Today())<=6&&DateDiff(ThisItem.'Last Time Cleaned',Today())<=7,Color.Orange,DateDiff(ThisItem.'Last Time Cleaned',Today())>=7,Color.Red)

     

    Now my gallery looks like this and the machine change color as the days pass.

    Chrisguff12_7-1612566137074.png

     

    Thanks again for your help.

  • Verified answer
    JR-BejeweledOne Profile Picture
    JR-BejeweledOne 5,825 on at
    Re: Color changing items in dropdown by date.

    You could do the percentage thing too.  Either would work, but you will have to have some sort of date/time calculation.

     

    Consider this:

     

    On App Start set a variable containing the current Date Time, using the Now() function.

     

    Collect your computers into a collection and use the AddColumn function to add a column that pulls in the date/time from the last cleaning report.

     

    Use this collection as your gallery data source.    In the fill statement, you can do a calculation, something like this:

     

    If(

    varNow - datetime field = XXXNumber, color,

    DefaultColor)

     

    Here is an example.   I don't have any date/time calculations here but you can see how it could be done.  The numbers are just random numbers I selected.   In the gallery you don't have to display any fields but the computer name.

     

    GalleryColors.png

     

    If you haven't used the AddColumns function before, here is a link for you:

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-table-shaping

  • Chrisguff12 Profile Picture
    Chrisguff12 223 on at
    Re: Color changing items in dropdown by date.

    Thanks, JR-BejeweledOne for the date components link. I will be need it for another app I'm making.

     

    I am ok with using a gallery or anything else make this work. but I don't want to set a color to a specific day of the week. I want the object/Label or what ever to change as time passes.

    Example:

    on Monday I clean machine A1 then the object will turn Green. Then by Friday the object will have automatically changed to more of a yellow/reddish color. Then if the machine hasn't been cleaned by Monday I don't want it to turn back to green. It will only change back to green after someone submits a cleaning report. Similar to a battery, it will only be at 100% after you charge it. 

     

    And thinking about batteries. If there is not a way to have an object change colors over time. Is there a way to add a percentage label that would go down over time. Then I could change the color of the percentage label based on its number?

  • JR-BejeweledOne Profile Picture
    JR-BejeweledOne 5,825 on at
    Re: Color changing items in dropdown by date.

    Maybe instead of a dropdown use a gallery.   And set the background (fill) and text (color) based on the date or day of the week.  That would be an instant visual and they could see all computers at once.

     

    Here is an article on getting the various date components.

     

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

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard