# If statements on expression binding on a labels text property

**URL:** <https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575>\
**Category:** Ignition\
**Created:** [December 28, 2023, 4:05pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575 "2023-12-28T16:05:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [December 28, 2023, 4:05pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575/1 "2023-12-28T16:05:32Z")

</div>

How do I do something like this on a text prop of a label. I want the label to change based on the dropdown selection.

```auto
if {../Dropdown.props.value} = 0 
	....
if {../Dropdown.props.value} = 1
	...

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 28, 2023, 4:27pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575/2 "2023-12-28T16:27:35Z")

</div>

Use an expression binding.

```auto
case({../Dropdown.props.value},
    1, "A partridge in a pear tree",
    2, "Two turtle doves",
    3, "Three French hens",
    4, "Four calling birds",
    5, "Golden rings",
    "Unknown 12 Days of Christmas gift"
)

```

[![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9adff265016e743aa2a0e1845499f0d971ba2b0.jpeg "Pentatonix - 12 Days Of Christmas (Official Video)") ](https://www.youtube.com/watch?v=1UHmQANFtNs)

[https://docs.inductiveautomation.com/display/DOC81/case](https://docs.inductiveautomation.com/display/DOC81/case)

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [December 28, 2023, 4:35pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575/3 "2023-12-28T16:35:00Z")

</div>

Merry Christmas !

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 28, 2023, 4:38pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575/4 "2023-12-28T16:38:31Z")

</div>

As an aside, you can't write _programs_ in an expression. Think of them like Excel functions. To make your expression work with `if` you would need,

```auto
if(({../Dropdown.props.value} = 1,
  "A partridge in a pear tree",
  if({../Dropdown.props.value} = 2, 
      "Two turtle doves",
      if({../Dropdown.props.value} = 3, 
        "Three French hens",
        if({../Dropdown.props.value} = 4, 
          "Four calling birds",
          if({../Dropdown.props.value} = 5, 
            "Golden rings",
            "Unknown 12 Days of Christmas gift"
)))))

```

It's not pretty!

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [December 28, 2023, 4:38pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575/5 "2023-12-28T16:38:38Z")

</div>

the comma after "tree" needs to be outside the quotation mark.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 28, 2023, 4:39pm UTC](https://forum.inductiveautomation.com/t/if-statements-on-expression-binding-on-a-labels-text-property/83575/6 "2023-12-28T16:39:21Z")

</div>

Fixed, thanks.  
Merry Christmas!
