# Display 0 for NaN

**URL:** <https://forum.inductiveautomation.com/t/display-0-for-nan/72522>\
**Category:** Ignition\
**Created:** [April 17, 2023, 11:49am UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522 "2023-04-17T11:49:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 17, 2023, 11:49am UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/1 "2023-04-17T11:49:52Z")

</div>

I have an expression tag that takes a tag value and divides it by another tag value. When these tags reset in the evening the expression tag changes to NaN im assuming because its dividing by 0 when one of the other tags resets to 0. Is there a way to make NaN display 0 instead of NaN? At the end of the day its not a huge deal because the tag serves its purpose its intended for, however, visually it is bothering me for the time period the division tags are at 0 until they start counting again.

Hopefully that makes sense....

---

<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:** [April 17, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/2 "2023-04-17T12:04:40Z")

</div>

If it's an expression tag, you could use something like

```auto
if ({divider_tag} != 0,
    {some_value} / {divider_tag},
    0
)

```

---

<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:** [April 17, 2023, 12:19pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/3 "2023-04-17T12:19:57Z")

</div>

Is NaN treated as an error? If so, you could use the try function,  
[https://docs.inductiveautomation.com/display/DOC80/try](https://docs.inductiveautomation.com/display/DOC80/try)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 17, 2023, 2:24pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/4 "2023-04-17T14:24:17Z")

</div>

Unfortunately try() won't work, as the actual division doen't generate an error. The TypeConversoin error happens after. Use Pascal's. 🙂

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 18, 2023, 12:13pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/5 "2023-04-18T12:13:54Z")

</div>

I thought I had this sorted out but I was wrong. Let me try to clarify a bit more.  
You have 1 expression tag here and 2 OPC Tag....all floats.

Main Tag A = Expression Tag value that is displayed on ignition screen. We call this main tag because its the one giving the type conversion error.  
Tag B = OPC tag Value that is reset daily at 5am to 0.  
Tag C= OPC Tag Value that is reset daily at 5am to 0.

Main Tag A is simply using the expression {Tag B} / {Tag C}. The value that is displayed gives us the type conversion error because at 5am Tag B and Tag C are being reset to 0, therefore Tag A is trying to do 0 divided by 0, in which lies the issue. Once Tag B and C have values, Tag A works perfectly as intended, i just dont want NaN being displayed on the screen after the reset happens.

I know im close but still doing something wrong. I did get the error to go away but the tag then didnt have any value at all. Appreciate 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:** [April 18, 2023, 12:20pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/6 "2023-04-18T12:20:20Z")

</div>

> [@kaleb.s](#):
>
> I know im close but still doing something wrong.

Show your expression in your expression tag. We can't identify the mistake you are making without seeing it.

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 18, 2023, 12:43pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/7 "2023-04-18T12:43:19Z")

</div>

> if ({Tag\_A} != 0,  
> {Tag\_B} / {Tag\_C},  
> 0  
> )

Removes the Type\_ErrorConversion from the value but then doesnt actually do the expression calculation. I may be understanding the syntax incorrectly. My understanding is if Tag A doesnt equal 0 then it will do the expression cal Tag B / Tag C. If it does equal 0, set the value to display 0.....

---

<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:** [April 18, 2023, 12:51pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/8 "2023-04-18T12:51:14Z")

</div>

If you want to avoid division by 0, you need to check the value that will be used to divide.

Replace tag\_A by tag\_C in the expression's condition.  
Which is exactly what I suggested previously.

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 18, 2023, 12:55pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/9 "2023-04-18T12:55:05Z")

</div>

I also tried that with the same result. Error in value is gone but it then doesnt actually do the division of the tags....

---

<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:** [April 18, 2023, 1:02pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/10 "2023-04-18T13:02:54Z")

</div>

Where did you use that expression ?  
This will result in a value, as long as tag\_c is not 0.

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 18, 2023, 1:15pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/11 "2023-04-18T13:15:30Z")

</div>

As stated above, Tag C gets reset to 0 at 5am every day. I used the expression in the expression field of the tag.

---

<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:** [April 18, 2023, 1:20pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/12 "2023-04-18T13:20:23Z")

</div>

Don't use `Tag_A` in the expression. That makes a loop, and is wrong anyways. I recommend this:

```auto
{Tag_B} / if({Tag_C}, {Tag_C}, 1.0e60)

```

The trailing large constant is to gracefully handle any execution that happens between `Tag_C` and `Tag_B` getting set to zero.

---

<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:** [April 18, 2023, 1:29pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/13 "2023-04-18T13:29:23Z")

</div>

Then at 5am every day, tag\_c won't be used in the calculation, because of the condition, and you'll just get 0.

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 18, 2023, 1:29pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/14 "2023-04-18T13:29:28Z")

</div>

Thank you sir! Appreciate you giving me a solution. Works perfectly!

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 18, 2023, 1:30pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/15 "2023-04-18T13:30:11Z")

</div>

You arent understanding fully i dont think. pturmel helped me out with a solution. Thank you for trying.

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 20, 2023, 11:26am UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/16 "2023-04-20T11:26:30Z")

</div>

This worked properly yesterday after the morning reset but today for some reason the value is staying at 0 and not doing the division. Any ideas?

---

<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:** [April 20, 2023, 11:42am UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/17 "2023-04-20T11:42:08Z")

</div>

We don't know what your code is. Post your expression code and format it using the \</\> button.

---

<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:** [April 20, 2023, 11:49am UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/18 "2023-04-20T11:49:15Z")

</div>

Is the expression tag assigned to a tag group?

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 20, 2023, 12:00pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/19 "2023-04-20T12:00:59Z")

</div>

If you read the entire thread you know what my code is. pturmel posted it above....

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [April 20, 2023, 12:01pm UTC](https://forum.inductiveautomation.com/t/display-0-for-nan/72522/20 "2023-04-20T12:01:46Z")

</div>

Its just assigned to the Default tag group.

[Next page](https://forum.inductiveautomation.com/t/display-0-for-nan/72522.md?page=2)
