# Conditional expression on tags that are often null? \[BEGINNER\]

**URL:** <https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 27, 2022, 4:54pm UTC](https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132 "2022-05-27T16:54:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Rzewnicki](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Mark\_Rzewnicki](https://forum.inductiveautomation.com/u/Mark_Rzewnicki)\
**Post date:** [May 27, 2022, 4:54pm UTC](https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132/1 "2022-05-27T16:54:40Z")

</div>

Hello,

I have a UDT containing multiple status integers with the same general meaning:

1 - Complete  
2 - Warning  
3 - On Hold

If any one of the status ints is equal to 3, the “on hold” designation applies to the entire instance.

I would like to add a boolean expression tag to this UDT that checks the values of all the status ints and evaluates as true if any of them is equal to 3.

The expression I wrote basically looks like: {[.]StatusInt1} \> 2 || {[.]StatusInt2} \> 2 … || {[.]StatusIntN} \> 2

This works sometimes, but other times the boolean tag shows a red exclamation with “Error\_ExpressionEval”

I think this is happening because the status ints are being set dynamically and the expression doesn’t like evaluating on a bunch of null values.

Any ideas on how I can do this cleanly or a point in the right direction would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 27, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132/2 "2022-05-27T17:09:40Z")

</div>

You can return a default value by using the `coalesce` expression.

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

I also might be tempted to do something more like:

```auto
max({[.]StatusInt1,{[.]StatusInt2},...) = 3

```

There are several ways to accomplish what you’re trying to do.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 27, 2022, 5:10pm UTC](https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132/3 "2022-05-27T17:10:01Z")

</div>

> [@Mark\_Rzewnicki](#):
>
> {[.]StatusInt1} \> 2

> [@Mark\_Rzewnicki](#):
>
> equal to 3

If it's `equal to 3`, use `= 3`.

the `coaslesce` expression function will do what you want. If you use `coalesce(x, true)` and x is null, it will return true.

---

<div class="post-metadata">

**Author:** ![Brandon\_Peterson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brandon_peterson/32/32960_2.png) [@Brandon\_Peterson](https://forum.inductiveautomation.com/u/Brandon_Peterson)\
**Post date:** [May 27, 2022, 5:24pm UTC](https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132/4 "2022-05-27T17:24:25Z")

</div>

Putting these two replies together, I think one of the following two solutions would work well for you:

Use `coalesce` to “safety check” each `StatusInt` in the expression. It would look something like this:

```auto
coalesce({[.]StatusInt1}, 0) = 3 || coalesce({[.]StatusInt2}, 0) = 3 || ...

```

Another possibility is to do this “safety check” in the expression for each `StatusInt` itself. You could, for example, say that the value `0` means the same thing as what `null` did before. That way, you’d only ever be dealing with non-null values, and your original solution would work.

```auto
StatusInt1 -> coalesce(<previous_expression>, 0)

```

```auto
{[.]StatusInt1} = 3 || {[.]StatusInt2} = 3 || ...

```

---

<div class="post-metadata">

**Author:** ![Mark\_Rzewnicki](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Mark\_Rzewnicki](https://forum.inductiveautomation.com/u/Mark_Rzewnicki)\
**Post date:** [May 27, 2022, 5:27pm UTC](https://forum.inductiveautomation.com/t/conditional-expression-on-tags-that-are-often-null-beginner/60132/5 "2022-05-27T17:27:38Z")

</div>

Thanks to all!

max(…) = 3 works like a charm :^D
