cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MJL1
Frequent Visitor

Set colour based on Status

I want to set the colour of my gallery row based on the value of the status field.  The pseudo code of what I think should be in the Fill attribute of the gallery is;

 

 

 

If (Status.selectedvalue.text = "Inactive", Gray, White)

 

 

 

 

I can't figure out the syntax to properly reference the text of the selected value of the status field.

 

Thanks in advance for your assistance.

1 ACCEPTED SOLUTION

Accepted Solutions
MJL1
Frequent Visitor

I found a solution.  I don't know if it's the "right" way to solve the problem but it works.  It feels like kind of a hack.

 

I added a label control to my gallery template and set it's visible property to false.  I set it's text property to ThisItem.Status.  I used this formula in the Fill property of the template If(lblStatus.Text = Text('Status (Regulatory Business Processes)'.Inactive), Gray, White)

View solution in original post

7 REPLIES 7
Drrickryp
Super User
Super User

@MJL1 

If(Status.Value = "Inactive", Gray, White)

A few clarification details.  I'm using a Dataverse.  The status column is a Choice data type with two values; "Active" and "Inactive".

 

@Drrickyp.  I tried what you proposed.  It results in an error.  I've attached a screenshot.  The error message says. "Incompatible types for comparison.  These types can't be compared: Error, Text"

 

jcfDaniel
Super User
Super User

Hi,

 

For Dataverse: Status = 'Status (Accounts)'.Inactive

 

Where you read accounts should be the name of the table you are using.


Regards. JD.

I'm still not certain how to use this to set the fill colour value for the gallery.  When I use this; 

 

If('Status (Regulatory Business Processes)' = "Inactive", Gray, RGBA(0, 0, 0, 0))

 

I get an error that says; "Incompatible types for comparison.  These types can't be compared: OptionSet(Status (Regulatory Business Processes)), Text."

 

I think I understand the error message - that is that, 'Status (Regulatory Business Processes)' is an OptionSet.  What I need, for my formula to work, is to be able to get the actual value that was selected for the Status column for a given record in the gallery.  'Status (Regulatory Business Processes)'.Selected.Text does not work.

jcfDaniel
Super User
Super User

Try this:

 

In a gallery: If ( ThisItem.Status = 'Status (Regulatory Business Processes)'.Inactive, Red, Green)


Regards. JD.

@jcfDaniel I get two errors with this statement.

The first is related to the "ThisItem.Status" part.  It says Invalid use of '.'.  The second error is the same as previously reported.

MJL1
Frequent Visitor

I found a solution.  I don't know if it's the "right" way to solve the problem but it works.  It feels like kind of a hack.

 

I added a label control to my gallery template and set it's visible property to false.  I set it's text property to ThisItem.Status.  I used this formula in the Fill property of the template If(lblStatus.Text = Text('Status (Regulatory Business Processes)'.Inactive), Gray, White)

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,147)