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 / Dynamic Conditional co...
Power Apps
Answered

Dynamic Conditional color formatting in a Gallery

(0) ShareShare
ReportReport
Posted on by 638

Hi, I'm in a situation where I need a different colour to be automatically attributed based on a condition.

 

I do not want to hardcode the conditions because they might change weekly.

 

I need the app to look at everything in a gallery that says "Commercial" and fill it Green, and I want it to look at a label that says Finance and turn Red. That is easy in itself with an if statement. but the issue is, Next week, a new department will be added and it's called "Property", I don't want to have to go back to the app and hardcode Property in the app.

 

In reality what I need is powerapps to group everything in their specific buckets based on the Department column, and spit out a colour per department, so everytime a new department is added or name is changed I dont have to go back and hardcode it again.

 

any ideas on how to achieve this?

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @jbrit2020 

    You will need to have a separate list (or augment an existing) to store the department names and colors.

    So, let's say you now have a list with a Department Name and color such as this:

    Title Color
    Commercial Green
    Finance Red
    Property Purple

     

    Since this is relatively static information, I would have the OnStart of the app gather the information with:

    Set(departmentColors, yourDepartmentList)

     

    Now for the Gallery control Color property:

       ColorValue(Coalesce(LookUp(departmentColors, Title=Self.Text, Color), "Black"))

     

    This will lookup the department in the table variable and return the color based on the text of the control.  If not found, it will default to Black.

     

    I hope this is helpful for you.

  • jbrit2020 Profile Picture
    638 on at

    Hi @RandyHayes, so this would be updated manually whenever a user adds a new department correct? They would also have to select a colour for the new department correct?

     

    This selection populates then the DepartmentList, and whenever a new record falls under certain department it will take it's colour.

     

    Can a colour picker be used for that purpose when a user is adding something to the departmentlist?

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

    @jbrit2020 

    Yes, your assumptions are correct.  A user would need to manually edit the department list and then the app would reflect those values (after app restart). 

     

    As for the picker for the colors, they would be valid color names only in text format.  If you want a color picker, then you would be talking about another app, or a part of your existing app to "maintain" that list of departments.  Certainly possible.

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
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard