Search code examples
powerappspowerapps-canvas

Looking to color code with two if condition in powerapps


I am looking to color code field with two if condition, Have tried the below code,

If(
   ('User Input - Unit'.Selected.Value = "Imperial") 
   Or ('User Input - Unit'.Selected.Value = "Metric")  
   && Value('Output'.Text) > 80,360, 
     RGBA( 220, 20, 60, 1 ), 
     RGBA( 127, 255, 212, 1 )
)

Solution

  • If you want to change the color when either "Imperial" or "Metric" is selected for User Input - Unit AND output value is greater than 80360, try using below formula:

    If(
        Or('User Input - Unit'.Selected.Value = "Imperial", 'User Input - Unit'.Selected.Value = "Metric") && Value('Output'.Text) > 80360,
        RGBA(220, 20, 60, 1),
        RGBA(127, 255, 212, 1)
    )
    

    Microsoft Documentation: And, Or, and Not functions in Power Apps


    Update from comments:

    Try using this formula:

    If(
        ('User Input - Unit'.Selected.Value = "Imperial" && Value('Output'.Text) > 80) || ('User Input - Unit'.Selected.Value = "Metric" && Value('Output'.Text) > 360),
        RGBA(220, 20, 60, 1),
        RGBA(127, 255, 212, 1)
    )