cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dkent
Helper I
Helper I

Conditional formatting on a label

I've looked through many posts on this and tried many of the suggestions but for the life of me do not understand why I can't get the condional formatting to work on a label. The label is set as view;

dkent_0-1617988990330.png

I want the border of the text box where it's displaying '12' to be red if the value is less than 1. I have tried many variation, nothing I can get to work though;

If(lbl_Vac-fld_DaysTaken<1,Red)

If(fld_vdr<1,Red,Grey) . . . just to name a couple.

 

Anyone have any Idea where I'm going wrong?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@dkent 

Yes, sorry, should be Gray.

 

Now, looking at your picture, you have a TextInput control, but it appears to be disabled or in view mode.

If it is in View mode, then you will NOT be able to change the border color as it will have none.

If it is disabled, then you need to change the DisabledBorderColor property.

If you have no need to have a user enter text, then I would get rid of the TextInput and just use a Label control instead.  With that you can change the border color without issue.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
RandyHayes
Super User
Super User

@dkent 

You must refer to properties of your controls, not to just the control.  

So your formula (which has nothing really to do with the color you want) in the Default property should be:

    If(fld_Absence_Type.Text = "Vacation", lblVac-fld_DaysTaken.Text, lbl_Vac.Text)

 

I assume all of the above reference other labels and not the control you are on.

 

As for the color, set your Color property to the following:

   If(Value(Self.Text) < 1, Red, Grey)

 

Now, I am not entirely sure what labels are what and where these are, but the above formula should be based on the results of those if you are using the default property as you are.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
dkent
Helper I
Helper I

Hello, I should have said Text Input rather than label. I tried that formula and it to throws an error.

dkent_1-1617990680527.png

Should I not be entering this formula in the BorderColor properties?

JoaoN
Helper IV
Helper IV

@dkentDid you try to use "Gray" instead of "Grey"?

@JoaoN -hehehe, ugh, thankyou it accepted "Gray", unfortunately the border color still doesn't change the value is less than 1:(

RandyHayes
Super User
Super User

@dkent 

Yes, sorry, should be Gray.

 

Now, looking at your picture, you have a TextInput control, but it appears to be disabled or in view mode.

If it is in View mode, then you will NOT be able to change the border color as it will have none.

If it is disabled, then you need to change the DisabledBorderColor property.

If you have no need to have a user enter text, then I would get rid of the TextInput and just use a Label control instead.  With that you can change the border color without issue.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Ahhh! ok, thank you so much! that worked. I had no idea there was disabled property setting. I will take your advice on the label as well. Thanks so much!

 

D

Hi @RandyHayes ,

 

I tried to use the formula If(Value(Self.Text)<0,Red,if(Value(Self.Text)>0,Green,White)), but got an error. Any idea why?

 

Thanks!

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.

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,291)