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 demonstrates how to change the item color in a gallery based on its value.

Showing the items in a different color can be incredibly useful for improving user experience and making it easier for users to spot important information quickly.

Here, we have a gallery displaying employee’s information.

Let’s modify the department color: if the department is “CS,” set the color to red, otherwise, keep it as black.

Select the department item in the gallery, then navigate to its color property, as shown below.




Now, write the following formula. It will check if the department is “CS” and change the color to red otherwise, it will remain black.

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

Note that,

Once you have completed this, you will see that the color has changed for the “CS” department.

Let’s update the colors for the other departments as well:
  • Blue for HR department
  • Green for Finance department
  • Black for the Delivery department

To achieve this, we need to modify the previous formula and replace the If condition with nested If statements to check for each department name.

Let’s write the following formula, which will check each department and assign the appropriate color.

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

You can now see that the colors have been updated 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.

Discover more from SQL BI Tutorials

Subscribe now to keep reading and get access to the full archive.

Continue reading