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 / Conditional Fill Color...
Power Apps
Answered

Conditional Fill Color Based on Selection

(0) ShareShare
ReportReport
Posted on by 14

I apologize for beating a dead horse. I have visited all the possible forum posts in regards to conditional formatting to adjust a fill color but can't seem to find one in the same scenario.

 

What I am attempting to do: In a PowerApp from a SP list is to use the value from a single choice dropdown where the choices are "Completed" "Scheduled" and "UnScheduled"

 

My rudimentary code in the Fill is as follows:

If('Final Photos Status_DataCard3'="Completed",Green, If('Final Photos Status_DataCard3'="UnScheduled",Red, If('Final Photos Status_DataCard3'="Scheduled",Yellow)))

 

I have a two fold issues which is I believe this is an invalid argument but being as it has been quite a while since I have coded anything like this I know I am just missing something. I also am getting the "PowerApps encountered an error while trying to evaluate this expression. Data Type: Control" message which I have been unable to resolve as of yet. 

 

Any insight from this community would be greatly appreciated!

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @GingerOfTech 

    Please consider changing your Formula to the following:

    Switch('Final Photos Status_DataCard3'.Selected.Value,
     "Completed", Green, 
     "UnScheduled", Red, 
     "Scheduled", Yellow
    )

     

    I hope this is helpful for you. 

  • GingerOfTech Profile Picture
    14 on at

    This is excellent, a much cleaner solution than I had originally been attempting. I have a remaining issue as I tried to place this exactly it came back with the error "Name isn't valid, this identified isn't recognized" however I have confirmed that the Card is still identified in PowerApps as 'Final Photos Status_DataCard 3' I altered the code to look at 'datacardvalue24' which holds the photo status in detail view and that works, however it changes all the entries to match the status of the first in the list.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @GingerOfTech 

    So to get this to work, you need to reference the proper property value of the control.

    I have assumed that you have a Dropdown control in your Datacard.  However I missed that you were not referring to the control properly.

     

    So I need some more information from you.

    What control are you trying to set the Fill on?  Is the control in your Gallery or in your Form (I am starting to lean toward, from your reply, that this is in a Gallery)?

    And finally, what is the name of the Column in your datasource that is the Choice column?

     

     

  • GingerOfTech Profile Picture
    14 on at

    Apologies, you are correct that it is in gallery. The goal is for the fill behind the title of each entry to reflect it's status. The name of the column in the datasource (my SP list) is "Final Photos Status"

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @GingerOfTech 

    Very good. Then your formula should be this:

    Switch(ThisItem.'Final Photos Status'.Value,
     "Completed", Green, 
     "UnScheduled", Red, 
     "Scheduled", Yellow
    )

     

    In the Gallery, you want to refer to the row values - this is in the ThisItem statement.  So, in the above we are looking at the row item (ThisItem) for the 'Final Photos Status' column and the value in that column.

  • GingerOfTech Profile Picture
    14 on at

    Exactly what I was needing, thanks for all your help!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @GingerOfTech 

    Happy to help.

  • Sharinah1 Profile Picture
    101 on at

    How to use switch function if based on number entry of user in DataCard1?

     

    red if >2

    amber = 1

    green = 0

     

  • Sharinah1 Profile Picture
    101 on at

    I used this it worked. 

     

    Switch(DataCardValue1.Text, "1", Yellow, "0", Green, Red)

  • Gina_Rolandi Profile Picture
    2 on at

    Hello,

     

    I am trying to do the same thing but theissue that I encounter is an "error" that says that my formula utilizes the "ambit", I'm not sure what it means, or if that's even the correct term because the message is originaly in spanish.

     

    Gina_Rolandi_2-1679486054167.png

     

    "Estado" refers to a sharepoint list column (named "EstadoTicket") and the value can either be "Pendiente" (pending) or "Resuelto" (solved).

     

    I want to make the fill color of "Estado" change depending of the value. 


    Can someones help me?

     

     

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
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard