# Multiple State IF

**URL:** <https://forum.inductiveautomation.com/t/multiple-state-if/32160>\
**Category:** Ignition\
**Created:** [February 12, 2020, 1:05pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160 "2020-02-12T13:05:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascale.croussette](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pascale.croussette](https://forum.inductiveautomation.com/u/pascale.croussette)\
**Post date:** [February 12, 2020, 1:05pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/1 "2020-02-12T13:05:48Z")

</div>

I try to make a multiple state IF.

Like,

If (Tag1) then 1

if (Tag2) then 2

else 0

How I can make It in ignition?

Thank you!

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [February 12, 2020, 1:19pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/2 "2020-02-12T13:19:34Z")

</div>

Pascale  
assuming the tags are bools  
in Expression

> if(Tag1,1,if(Tag2,2,0))

Scripting

```auto
value = 0
if Tag1 == 1:
    value = 1
elif Tag2 ==1:
    value = 2

```

But what do you want if both are true?

---

<div class="post-metadata">

**Author:** ![pascale.croussette](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pascale.croussette](https://forum.inductiveautomation.com/u/pascale.croussette)\
**Post date:** [February 12, 2020, 1:47pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/3 "2020-02-12T13:47:01Z")

</div>

If tag 2 and not Tag 1 then 2

Like this I think ?

if(Tag1,1,if((Tag2&&!Tag1),2,0))

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [February 12, 2020, 2:24pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/4 "2020-02-12T14:24:43Z")

</div>

Pascale, either will be fine (except you have one too many “)” on the right), the expression will evaluate Tag1 first and if true will return 1 even if Tag2 is also true, Tag1 has to be false for the second “if” to be evaluated so no real need for  
`&&!Tag1`

---

<div class="post-metadata">

**Author:** ![pascale.croussette](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pascale.croussette](https://forum.inductiveautomation.com/u/pascale.croussette)\
**Post date:** [February 12, 2020, 2:44pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/5 "2020-02-12T14:44:53Z")

</div>

It’s works well.

Thank you!

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 12, 2020, 2:48pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/6 "2020-02-12T14:48:32Z")

</div>

This post may be helpful as well...

> [@Expression Help with Fill Colors](http://forum.inductiveautomation.com/t/expression-help-with-fill-colors/31433):
>
> Hello Everyone, I am struggling with trying to select a fill color based off of an expression. Ultimately, I want a Numeric Label’s “Background Fill” to change color based off conditions. The tags that I need are a part of my Motor UDT. I was able to accomplish this easily in FactoryTalk but haven’t been able to in Ignition. Here’s the actual expression from FA: IF {[PLC\_100\_1\_1]C\_113\_20.Running} AND {[PLC\_100\_1\_1]C\_113\_20.Alarm} THEN 3 ELSE IF {[PLC\_100\_1\_1]C\_113\_20.Running} AN…

---

<div class="post-metadata">

**Author:** ![pascale.croussette](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pascale.croussette](https://forum.inductiveautomation.com/u/pascale.croussette)\
**Post date:** [February 12, 2020, 2:54pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/7 "2020-02-12T14:54:16Z")

</div>

I’m also a Factory Talk Familiar,

I will be good soon in Ignition To 😉

Thank you !

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [February 12, 2020, 3:01pm UTC](https://forum.inductiveautomation.com/t/multiple-state-if/32160/8 "2020-02-12T15:01:14Z")

</div>

Sorry, you will hate FactoryTrash after you see what you have been missing.
