# Report key calculation on boolean

**URL:** <https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123>\
**Category:** Ignition\
**Created:** [February 24, 2018, 8:57pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123 "2018-02-24T20:57:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [February 24, 2018, 8:57pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/1 "2018-02-24T20:57:57Z")

</div>

I’m having trouble with a key calculation in a table on a boolean value. I’m trying to replace the simple true/false word that comes into the simple table cell from the database query with just an “ON” for true and blank for false. I assumed the proper key calculation was something like:

```auto
@EndOfCycle== true ?"ON":""@

```

But nothing shows up in the cells that have the boolean as true for that cell. I tried comparing to 1, but then all the cells say “ON” regardless of the true/false status of the data from the database.

FYI, I pasted the query into the Database Query Browser, and that column is showing up as a checkbox, so I’m pretty sure it’s coming across as a true boolean datatype.

Any thoughts?

---

<div class="post-metadata">

**Author:** ![franklepkowski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/franklepkowski/32/4808_2.png) [@franklepkowski](https://forum.inductiveautomation.com/u/franklepkowski)\
**Post date:** [February 24, 2018, 11:29pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/2 "2018-02-24T23:29:08Z")

</div>

Maybe creating a string expression tag to convert the bool value to “ON” and pointing your table to this tag would solve your issue.

---

<div class="post-metadata">

**Author:** ![Claus\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Claus\_Nielsen](https://forum.inductiveautomation.com/u/Claus_Nielsen)\
**Post date:** [February 25, 2018, 12:22pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/3 "2018-02-25T12:22:26Z")

</div>

I think something like this should work

```auto
@EndOfCycle==1?"ON":""@

```

EDIT:  
Just tested, it works here.

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [February 26, 2018, 6:02pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/4 "2018-02-26T18:02:40Z")

</div>

I just tried again, and it isn’t working for me. What data source are you using? Maybe that has something to do with it. Mine is a postgresql table.

This is what I’m seeing. With just `@EndOfCycle@` :  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a24e62dbd9e505ec51511e0ae540a61a70e4f9f9.png)

With `@EndOfCycle==1?"ON":""@` :  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/04566e1145128f79dc6f9a4618dec506ae452708.png)

With `@EndOfCycle==true?"ON":""@` :  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/564661232578e95cbdb18ef51ca6a7a2d629ea00.png)

---

<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 26, 2018, 6:22pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/5 "2018-02-26T18:22:29Z")

</div>

Try:

```auto
@EndOfCycle?"ON":""@

```

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [February 26, 2018, 7:01pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/6 "2018-02-26T19:01:38Z")

</div>

```auto
@EndofCycle?"ON:""@

```

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/d26715a6582395f59484a267553d54265d784d9e.png)

Looks like that’s working. The weird thing is, according to the docs I was reading, it shouldn’t work like that. Just the ? without a conditional should be testing for null/not-null.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c5733affca929b11fc745ac68e1075ccaa1292d6.png)  
^That’s from [this page](https://docs.inductiveautomation.com/display/DOC79/Keychain+Expressions).

I guess it behaves differently for boolean values. Never thought to try it. Thanks for pointing me in the right direction. 🙂

---

<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 26, 2018, 7:10pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/7 "2018-02-26T19:10:43Z")

</div>

I was just mentally applying python rules for casting to boolean.

---

<div class="post-metadata">

**Author:** ![Claus\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Claus\_Nielsen](https://forum.inductiveautomation.com/u/Claus_Nielsen)\
**Post date:** [February 26, 2018, 9:25pm UTC](https://forum.inductiveautomation.com/t/report-key-calculation-on-boolean/17123/8 "2018-02-26T21:25:35Z")

</div>

I tried the python way aswell without any luck
