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

Multiple if functions based on calculated field and selection

Hi,

 

the situation is as follows. I have an edit form where I fill several fields and make a selection (6, 8, 10, 12, 16). Based on the entries and selection, value is calculated and presented in a label.

I want the label to change its color (indication that it meets the requirements) based on the calculated value and the selection: 6, 8, 10, 12, 16. The problem is that limit value (calculated based on the entries in edit form) for selections is different:

 

for 6 it is >0.5

for 8 it is >0.6

and etc.

 

Any ideas how to write the if functions for all the selections? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

@Concrete 

Yes, so then with choices, your values will all be text.  You need to convert.

Try this formula instead:

With({labelValue:Value(Self.Text)},

    Switch(Value(DataCardValuex.Selected.Value),
        6, If(labelValue > .5, Green, Red),
        8, If(labelValue > .6, Green, Red)
    )
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

9 REPLIES 9
RandyHayes
Super User III
Super User III

@Concrete 

If your label is what is displaying the "0.5", "0.6" etc,  then you can put a formula on the Fill property of the label like this:

With({labelValue:Value(Self.Text)},

    If(labelValue > .6, Red,
       labelValue > .5, Yellow,
       labelValue > .4, Green
    )
)

Note, you should do your higher leve4l comparisons in a descending order.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes 

 

I want label to have only two colors: red - if it is lower than limit value (doesn't meet the requirements) and green - higher than limit value (meets the requirements). The thing is that the limit value for different selections 6, 8, 10, 12, 16 is different:

 

for 6 it is >0.5

for 8 it is >0.6

 

How do I show in if function to first look into the selection (6, 8, 10, 12, 16) and then change color of label based on the comparison between calculated value and specific limit value?

@Concrete 

So the first question is Where is the 6, 8, 10, 12 etc. entered?  Is this in a TextInput control or a DropDown or ComboBox?  And what is the name of that Control?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes ,

 

it is DropDown - DataCard1.

@Concrete 

Okay, so DataCard1 is not going to most likely be the name of the control.  If this is in an EditForm, then you will have a control in your DataCard1 - something like DataCardValuex

 

That is what you will want to use in your Label Fill formula:

With({labelValue:Value(Self.Text)},

    Switch(DataCardValuex.Selected.Value,
        6, If(labelValue > .5, Green, Red),
        8, If(labelValue > .6, Green, Red)
    )
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes ,

 

When I post it to my Label Fill field I get an error. I have indicated DataCardValue11. Probably I don't understand something here.

@Concrete 

What is the DataCardValue11 control?  My understanding was that it was a DropDown.  What is the Items property of the control?

Also, you mention you get an error...what is the error?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes 

 

DataCardValue11 control is dropdown. Items property of it is - Choices([@'XXXX'].Diameter_x002c__x0020_mm)

 

Error - Invalid argument type (Number). Expecting a text value instead.

@Concrete 

Yes, so then with choices, your values will all be text.  You need to convert.

Try this formula instead:

With({labelValue:Value(Self.Text)},

    Switch(Value(DataCardValuex.Selected.Value),
        6, If(labelValue > .5, Green, Red),
        8, If(labelValue > .6, Green, Red)
    )
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (60,051)