# Ignition Expressions compare quality values

**URL:** <https://forum.inductiveautomation.com/t/ignition-expressions-compare-quality-values/55830>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [February 7, 2022, 8:35pm UTC](https://forum.inductiveautomation.com/t/ignition-expressions-compare-quality-values/55830 "2022-02-07T20:35:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul.longtine](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.longtine/32/10599_2.png) [@paul.longtine](https://forum.inductiveautomation.com/u/paul.longtine)\
**Post date:** [February 7, 2022, 8:35pm UTC](https://forum.inductiveautomation.com/t/ignition-expressions-compare-quality-values/55830/1 "2022-02-07T20:35:58Z")

</div>

The problem de jour is taking an existing tag, and testing for a particular quality value with an Ignition expression.

With the expression function library, I can use the `qualityOf` function to pull out just the QualityCode value. At the moment, I am only successfully able to test against this quality code with the integer value representation - which is workable, just cryptic.

For instance, if I want to return different values based off of the quality code using a `case` statement, I would write that as:

```
case(qualityOf({<tag_path>}), -2147483124, "Out of range!", "")

```

Ideally, I’d like to have the enumerated value used in this `case` statement for better readability when combining many quality codes into a single `case` statement, like so:

case(qualityOf({\<tag\_path\>}), QualityCode.Bad\_OutOfRange, “Out of range!”, “”)

I understand it is also possible to dive into a Python script and expose quality codes via an import: `from com.inductiveautomation.ignition.common.model.values import QualityCode`

I am trying to avoid using a script for this logic for performance reasons.

Thank you,

- Paul

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 7, 2022, 8:40pm UTC](https://forum.inductiveautomation.com/t/ignition-expressions-compare-quality-values/55830/2 "2022-02-07T20:40:07Z")

</div>

But an enumerated value is not a number that could be used with the result of qualityOf(). They are objects. Ignition’s expression language doesn’t really do objects, other than a few special cases. That’s a big part of what makes them fast.

---

<div class="post-metadata">

**Author:** ![paul.longtine](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.longtine/32/10599_2.png) [@paul.longtine](https://forum.inductiveautomation.com/u/paul.longtine)\
**Post date:** [February 7, 2022, 8:49pm UTC](https://forum.inductiveautomation.com/t/ignition-expressions-compare-quality-values/55830/3 "2022-02-07T20:49:33Z")

</div>

I figured as much. Thanks for the response.

I was wishing that there was a builtin #define in the expression language interpreter that would be able to swap out friendly symbols with the associated integer values, and I was just being blind to those symbols. Another item for the wishlist then 🙂

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 7, 2022, 11:32pm UTC](https://forum.inductiveautomation.com/t/ignition-expressions-compare-quality-values/55830/4 "2022-02-07T23:32:43Z")

</div>

I don’t know if I’d call this a _good_ idea, necessarily, but `toString(qualityOf())` returns the human readable string _for our predefined codes_. You could still have values that fall out of our expected range, but as long as they’re appropriately handled by the case that could work.
