# Table cell displays NaN for small number (Bug ?)

**URL:** <https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 2, 2023, 4:47pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503 "2023-06-02T16:47:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [June 2, 2023, 4:47pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/1 "2023-06-02T16:47:34Z")

</div>

I have linked a dataset to a table in perspective. The table does not show scientific notation. When I enter values is removes the scientific notation.

Example:

The value in the dataset is 6.9592e-8. The table displays NaN. (see below).

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

When I double click on the field to edit the value I can see the correct value:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0d6779876f5b7a365f79782792ef3e34a6906624.png)

However, when I enter the value 7.8888e-8 and press enter the value is converted to 7.89 (no scientific notation)

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

result after pressing enter:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/7440c105c136bb18b86d57927d0eb1104fef67d4.png)

The column formatting is set as follows.

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

I changed the number format from 0,0.## to "0.00e+0"  
The displayed value is correct (no longer NaN) but when I enter a new value , it displays e+0 rather than e-8. Plus, I don't want my values all displayed in scientific notation, just the very big and very small numbers.

Is this a bug or am I doing something wrong ?

---

<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:** [June 2, 2023, 4:53pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/2 "2023-06-02T16:53:23Z")

</div>

Check that you're not passing scientific notation as a string.

> [@Percent Values show as NaN% if they're very small in number format table column](https://forum.inductiveautomation.com/t/percent-values-show-as-nan-if-theyre-very-small-in-number-format-table-column/25554/2):
>
> I fixed it. It’s because my Python script was passing very-small values as STRINGS in scientific notation (i.e: "1.53421e-9") instead of as an actual number. This caused Ignition to throw up a NaN when it was given a string instead of a numeric value. Adding code to account for this and force very small numbers to 0 fixed the problem.

---

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [June 2, 2023, 4:59pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/3 "2023-06-02T16:59:19Z")

</div>

That's great.. Can you show where you put the code and examples of the code ?

---

<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:** [June 2, 2023, 5:10pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/4 "2023-06-02T17:10:32Z")

</div>

I've never actually run into the problem. I happened to see the other post in the last couple of days and remembered it.

You have two choices. If the dataset is coming from a database query you could sort it out at the SQL level. If not (or if the dataset is coming from something else) you could run a script transform on the dataset.

Please explain your configuration and what you want to happen with small numbers. e.g., Do you want to round anything below 0.0005 to zero?

---

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [June 2, 2023, 5:23pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/5 "2023-06-02T17:23:27Z")

</div>

The dataset column I am writing to is the type float.

Here is the original code in "onEditCellCommit"

```auto
def runAction(self, event):
	valueToSet = event.value
	system.perspective.print(valueToSet)
	newData = system.dataset.setValue(self.props.data, event.row, event.column, event.value)
	system.tag.writeBlocking('[s1500]UnitConversion/UnitConversionTable', newData)
	system.perspective.print("new value entered:{} Row:{} Col:{} ".format(valueToSet, event.row,event.column))
	
	

```

console ouput:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/a/ea4f2e7877d7ac24f271cd3b9c5be98bd24250bb.png)

When I tried converting event.value to float it still produces the same problem:

```auto
def runAction(self, event):
	valueToSet = float(event.value)
	system.perspective.print(valueToSet)
	newData = system.dataset.setValue(self.props.data, event.row, event.column, event.value)
	system.tag.writeBlocking('[s1500]UnitConversion/UnitConversionTable', newData)
	system.perspective.print("new value entered:{} Row:{} Col:{} ".format(valueToSet, event.row,event.column))
	

```

browser console output:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/833234a72f7df3ed5240786f7415aa6a66a202ce.png)

Table display after entering value of 7.8888e-8: (incorrect)

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

note that the table is bound to the memory dataset tag "[s1500]UnitConversion/UnitConversionTable", bidirectional is unchecked

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/62428051ffb7f7cd661dfcfc7a5031154a9352ac.png)

---

<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:** [June 2, 2023, 5:39pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/6 "2023-06-02T17:39:55Z")

</div>

Again, I may not be your best hope of success. It's still not clear to me whether 6.9592e-8 is the actual value you want to store or if it's a rounding error that you want to get rid of. If it's the latter can you use a Python / Jython floor() function?

---

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [June 2, 2023, 6:09pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/7 "2023-06-02T18:09:27Z")

</div>

Yes, I want to store very small numbers like 7.8888e-8. ( and very large ones too ) I know there are rounding errors when you get into the weeds with floating point storage but I am not worried about those errors I just want to understand why the exponent is removed when I enter values into the data table.

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [June 2, 2023, 8:11pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/8 "2023-06-02T20:11:38Z")

</div>

A bug is part of your issue:

> [@\[IGN-7725\] Perspective table has trouble displaying tiny double/float values](https://forum.inductiveautomation.com/t/ign-7725-perspective-table-has-trouble-displaying-tiny-double-float-values/73602):
>
> Bumped into this one on production... disappointed We had a table with a column that was so close to zero as to be irrelevant, and the Perspective table just shows NaN... Paste this into a table's data property and you get it right away: [{ "TinyValue": 7.496146992025388e-8 }] If I change the numberFormat setting for the TinyValue column to "none" or "scientific" it will start working but display excessive detail. I really just want it to show a "0" or "0.00". This also happens using a …

---

<div class="post-metadata">

**Author:** ![justin.brzozoski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justin.brzozoski/32/13452_2.png) [@justin.brzozoski](https://forum.inductiveautomation.com/u/justin.brzozoski)\
**Post date:** [June 2, 2023, 8:18pm UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/9 "2023-06-02T20:18:27Z")

</div>

And in your example code you have the line:

```auto
system.tag.writeBlocking('[s1500]UnitConversion/UnitConversionTable', newData)

```

The parameters to writeBlocking need to be lists:

```auto
system.tag.writeBlocking(['[s1500]UnitConversion/UnitConversionTable'], [newData])

```

---

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [June 3, 2023, 12:36am UTC](https://forum.inductiveautomation.com/t/table-cell-displays-nan-for-small-number-bug/74503/10 "2023-06-03T00:36:13Z")

</div>

Thanks for input ! I will fix my code and wait for bug fix.
