0

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 )
)
jasonscript
  • 6,039
  • 3
  • 28
  • 43
Gandalf
  • 17
  • 3

2 Answers2

1

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)
)
Ganesh Sanap
  • 1,386
  • 1
  • 8
  • 18
0

My guess is that your formula has a number in the last condition with a thousand separator ( 80,360 ). The comma separator collides with the the Power Apps expression language, since it already reserved comma to separate function arguments.

If( ('User Input - Unit'.Selected.Value = "Imperial") Or ('User Input - Unit'.Selected.Value = "Metric") && Value('Output'.Text) > 80360, RGBA( 220, 20, 60, 1 ), RGBA( 127, 255, 212, 1 ))
mmikesy90
  • 783
  • 1
  • 4
  • 11
  • Thanks for the reply, my case is if "Imperial" is selected and the value exceeds 80 it should fill with color as mentioned and if "Metric" is selected and the value exceeds 360 the same follows. – Gandalf Aug 16 '23 at 03:58