# How would I write an expression to change the state of a multi state indicator depending on two tags?

**URL:** <https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301>\
**Category:** Ignition\
**Tags:** vision, scripting\
**Created:** [May 5, 2023, 3:48am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301 "2023-05-05T03:48:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [May 5, 2023, 3:48am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301/1 "2023-05-05T03:48:44Z")

</div>

I am fairly new to ignition and was wondering how could I change the state of the multi state indicator depending on which tag value increases.  
I was writing a Property Binding Expression but it does not work.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 3:55am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301/2 "2023-05-05T03:55:10Z")

</div>

An expression binding on the state property should work. What is your expression? What states do you want and under what specific conditions?

---

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [May 5, 2023, 3:58am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301/3 "2023-05-05T03:58:54Z")

</div>

I have 2 states, pass and fail. And I have two tags connected to a plc. So, if tag A increases I want the indicator to be in state 1(Pass) and if tag B increases I want the indicator to be in state 2 (fail).

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 4:07am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301/4 "2023-05-05T04:07:32Z")

</div>

What are the datatypes of these tags?

---

<div class="post-metadata">

**Author:** ![Shirshak\_Chhetri](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@Shirshak\_Chhetri](https://forum.inductiveautomation.com/u/Shirshak_Chhetri)\
**Post date:** [May 5, 2023, 4:07am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301/5 "2023-05-05T04:07:53Z")

</div>

Integers.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 4:15am UTC](https://forum.inductiveautomation.com/t/how-would-i-write-an-expression-to-change-the-state-of-a-multi-state-indicator-depending-on-two-tags/73301/6 "2023-05-05T04:15:45Z")

</div>

For me, it would be easier to script this. Simply add two custom properties to your component, and bind your tags to them, and then, use the component's propertyChange event handler to drive the state.

**Example:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d047ad33e916a5c76132fc43b5a646c7b6b80459.png)

```auto
if event.propertyName == 'tag1' and event.newValue > event.oldValue:
	event.source.state = 0
elif event.propertyName == 'tag2' and event.newValue > event.oldValue:
	event.source.state = 1

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/9/d9cfc39363eaacd85845c57fda24b97216b58c52.png)
