Skip to content
Home ยป Change gallery item color based on value in power apps

Change gallery item color based on value in power apps

This article demonstrate how to change item color based on value in gallery.

As you can see, here we have a gallery which contains employee information.

Lets change the department color , if department is CS then change the color to Red otherwise keep it black.

Select department item in gallery then go to the item color property of item as shown below.




Now write the below code, this code will check if department is CS then change the color to red else black.

If(
ThisItem.Department = "CS",
Red,
Black
)

Once you done with this, you can see the color is changed for CS department.

Lets change the color for other departments as well.

Blue color for HR, green color for Finance, black for Delivery department.

For this, we need to modify above code and replace the if condition with nested if condition to check all the department names.

Lets write the below code, which check for each department and assign them color.

If(
ThisItem.Department = "CS",
Red,
If(
ThisItem.Department = "Finance",
Green,
If(
ThisItem.Department = "HR",
Blue,
Black
)
)
)

Now you can see, color is changed for all departments accordingly.





Also read..

Highlight the selected item in gallery

Add Alternate background color to rows

Sort Items in gallery Power Apps

 

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.