cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Talha
Level: Powered On

Color the Gallery items based on Categories

Hi.,

 

i have listed all Projects in gallery from Project table. the Project having multiple categories like IT, HR Account etc.

My requiremnet is i need to color the gallary items based on the categories as below:

 

the category is added in Project table with a column name "category"

cat.PNG

 

Is possible to check the category of next items in gallery. or any other way to achieve this

 

thanks

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Color the Gallery items based on Categories

You can use a Switch (or an If) expression for the Fill and Color properties of the labels in the gallery that takes a dependency of the category of the current item. The attached app has an example of those with your data, and the expressions used on it are shown below. This is the expression used for the Fill property of the label:

Switch(
    ThisItem.Category,
    "IT", RGBA(127, 255, 127, 0.3),
    "HR", RGBA(255, 255, 127, 0.3),
    "Account", RGBA(255, 127, 127, 0.3),
    RGBA(255, 255, 255, 0))

And this one for the color:

Switch(
    ThisItem.Category,
    "IT", RGBA(63, 127, 63, 0.7),
    "HR", RGBA(127, 127, 63, 0.7),
    "Account", RGBA(127, 63, 63, 0.7),
    RGBA(0, 0, 0, 1))
Community Support Team
Community Support Team

Re: Color the Gallery items based on Categories

Hi @Talha,

 

Do you want to color the Gallery items based on the category of the project?

 

I have made a test on my side, please take a try with the following workaround:7.JPG

 

 

Set the TemplateFill property of the Gallery control to following formula:

 

If(
ThisItem.Category="IT",
RGBA( 152, 251, 152, 1 ),
ThisItem.Category="HR",
RGBA(255, 255, 127, 0.3),
ThisItem.Category="Account",
RGBA( 255, 192, 203, 1 )
)

If you have more categories within your Project table, please type the following formula:

 

If(
ThisItem.Category="IT",
RGBA( 152, 251, 152, 1 ),
ThisItem.Category="HR",
RGBA(255, 255, 127, 0.3),
ThisItem.Category="Account",
RGBA( 255, 192, 203, 1 ),
ThisItem.Category="xxx",
RGBA(..,..,),
...
)

 

In addition, you could also consider take a try with @CarlosFigueira's thought. Please type the following formula:

 

Switch(
ThisItem.Category,
"IT",RGBA( 152, 251, 152, 1 ),
"HR",RGBA(255, 255, 127, 0.3),
"Account",RGBA( 255, 192, 203, 1 )
)

 

 

More details about If function and Switch function in PowerApps, please check the following article:

If function and Switch function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Color the Gallery items based on Categories

You can use a Switch (or an If) expression for the Fill and Color properties of the labels in the gallery that takes a dependency of the category of the current item. The attached app has an example of those with your data, and the expressions used on it are shown below. This is the expression used for the Fill property of the label:

Switch(
    ThisItem.Category,
    "IT", RGBA(127, 255, 127, 0.3),
    "HR", RGBA(255, 255, 127, 0.3),
    "Account", RGBA(255, 127, 127, 0.3),
    RGBA(255, 255, 255, 0))

And this one for the color:

Switch(
    ThisItem.Category,
    "IT", RGBA(63, 127, 63, 0.7),
    "HR", RGBA(127, 127, 63, 0.7),
    "Account", RGBA(127, 63, 63, 0.7),
    RGBA(0, 0, 0, 1))
Community Support Team
Community Support Team

Re: Color the Gallery items based on Categories

Hi @Talha,

 

Do you want to color the Gallery items based on the category of the project?

 

I have made a test on my side, please take a try with the following workaround:7.JPG

 

 

Set the TemplateFill property of the Gallery control to following formula:

 

If(
ThisItem.Category="IT",
RGBA( 152, 251, 152, 1 ),
ThisItem.Category="HR",
RGBA(255, 255, 127, 0.3),
ThisItem.Category="Account",
RGBA( 255, 192, 203, 1 )
)

If you have more categories within your Project table, please type the following formula:

 

If(
ThisItem.Category="IT",
RGBA( 152, 251, 152, 1 ),
ThisItem.Category="HR",
RGBA(255, 255, 127, 0.3),
ThisItem.Category="Account",
RGBA( 255, 192, 203, 1 ),
ThisItem.Category="xxx",
RGBA(..,..,),
...
)

 

In addition, you could also consider take a try with @CarlosFigueira's thought. Please type the following formula:

 

Switch(
ThisItem.Category,
"IT",RGBA( 152, 251, 152, 1 ),
"HR",RGBA(255, 255, 127, 0.3),
"Account",RGBA( 255, 192, 203, 1 )
)

 

 

More details about If function and Switch function in PowerApps, please check the following article:

If function and Switch function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.