# Keychain expression evaluate if true?

**URL:** <https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482>\
**Category:** Ignition\
**Tags:** ignition81, reporting\
**Created:** [January 6, 2025, 3:19pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482 "2025-01-06T15:19:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [January 6, 2025, 3:19pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/1 "2025-01-06T15:19:13Z")

</div>

I'm designing a report with the reports module and can't get my keychain expression to evaluate a bit type key. I have a square that I want to enable Fill if the value is True/1. I'm not sure what output a checkbox needs in order to enable it, also I'm not sure if I need to evaluate for "True" or "1" or 1.

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

So far, I've tried `Value=="1"?"1":"0"`, `Value=="1"?"True":"False"`, `Value=="True"?"1":"0"`, and `Value=="True"?"True":"0"` and they all return as Fill enabled.

Thanks for the help!

---

<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:** [January 6, 2025, 3:24pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/2 "2025-01-06T15:24:31Z")

</div>

Don't compare. Just use the key.

---

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [January 6, 2025, 3:26pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/3 "2025-01-06T15:26:21Z")

</div>

What if I wanted to use the opposite of the key? `!Key`?

edit: Yes, `!Key` is the inverse of the key.

---

<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:** [January 6, 2025, 4:22pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/4 "2025-01-06T16:22:24Z")

</div>

~~The `==` syntax is for Python / Jython. It won't work in expressions.~~

~~In Expression Language `=` (the Equal operator) tests for equality between two operands.~~

---

<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:** [January 6, 2025, 4:32pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/5 "2025-01-06T16:32:07Z")

</div>

> [@Transistor](#):
>
> It won't work in expressions.

This is reporting. Keychain expressions **do** use `==` for equality:

> **[Keychain Expressions | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/reporting/report-design/data-keys/keychain-expressions#operators-and-functions)**
>
> It's possible to perform calculations on data keys. This section documents the various operators and functions that are available.

---

<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:** [January 6, 2025, 5:27pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/6 "2025-01-06T17:27:36Z")

</div>

Hmmmph! How come I've never come across keychain expressions before? Am I not doing enough reports?

---

<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:** [January 6, 2025, 6:00pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/7 "2025-01-06T18:00:04Z")

</div>

> [@Transistor](#):
>
> Am I not doing enough reports?

Perhaps. Or, like me, you compute the bits you need in SQL or your scripted data source so that all of your data key references need no expression.

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [January 6, 2025, 8:01pm UTC](https://forum.inductiveautomation.com/t/keychain-expression-evaluate-if-true/100482/8 "2025-01-06T20:01:07Z")

</div>

I use Reporting heavily...and keychain expressions come in handy when dynamically changing text color if a value exceeds a threshold for example.

Another simple use of keychain expressions is to dynamically change the row color without the need of using row versioning. Here is a quick example.

`(Row % 2==0)?"B7B7B7FF","FFFFFFFF"`

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8c3f08827384642ad83cae849cd8542da96baa55.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/2/72c9dfdf75a8dc41834a11d523734054927c3aa5.png)
