# RootContainer Custom Property Type for Mysql Decimal(5,2)

**URL:** <https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [January 21, 2020, 7:47pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486 "2020-01-21T19:47:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [January 21, 2020, 7:47pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/1 "2020-01-21T19:47:56Z")

</div>

I am trying to use a custom property to display a Decimal(5,2) column from a Mysql5.6 table.  
I originally set it to Type: Float but the result is 305.1199996 instead of 305.12  
I tried all the existing Types (ver.7.94) and I either get 305 or 305.1199996

Again, the table column’s type is Decimal(5,2) and below is my custom

 ![power%20table%20try%20deciaml(5%2C2)](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2f1b745b99e8da989e8dfe7ef4c5204e2913d5a5.png) property binding.

What are my options to get the custom property to display 305.12?

---

<div class="post-metadata">

**Author:** ![boyergary](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/boyergary/32/10316_2.png) [@boyergary](https://forum.inductiveautomation.com/u/boyergary)\
**Post date:** [January 21, 2020, 7:57pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/2 "2020-01-21T19:57:17Z")

</div>

In the expression editor, you’ll find a math function that can round for you (see screenshot). Just put your expression inside the function.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/245d645f24b009a5ead87fe0da0702bf7be42b70.png)

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [January 21, 2020, 8:07pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/3 "2020-01-21T20:07:55Z")

</div>

I just attempted the following Expression and received this Error msg - Syntax Error on Token:‘COMMA’(Line 1, Char 104). I made some tries at modifying th esyntax but kept getting other mistake errors.

```
round((try({Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6], 100.1), 2)
```

---

<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:** [January 21, 2020, 8:07pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/4 "2020-01-21T20:07:58Z")

</div>

To expand a little bit: Ignition doesn’t/can’t use precise decimal types when returning data from databases, for complex reasons, so the value is coerced into a 32-bit or 64-bit IEEE754 floating point number, which does _not_ have arbitrary precision; so `305.11999996` _is_ the “exact” representation Java has for the number. Rounding on output is the ‘correct’ way to present that information; or, if you don’t need to do any actual math with it, you can also cast _in your query_ as a string, which will allow the DB to preserve the precision information on the DECIMAL column.

Also, you had an extra open parentheses in your expression. Try:

```auto
round(
	try(
		{Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6]
		, 100.1
	)
	, 2
)

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [January 21, 2020, 8:12pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/5 "2020-01-21T20:12:27Z")

</div>

This expression gave me Type mismatch in operation ‘round’: expected ‘Number’, found ‘Object’

```
round(try({Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6], 100.1), 2)
```

---

<div class="post-metadata">

**Author:** ![boyergary](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/boyergary/32/10316_2.png) [@boyergary](https://forum.inductiveautomation.com/u/boyergary)\
**Post date:** [January 21, 2020, 8:16pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/6 "2020-01-21T20:16:24Z")

</div>

> [@paul-griffith](#):
>
> {Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6]

You just want to put the round around the expression, not the try:  
round({Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6], 2)

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [January 21, 2020, 8:22pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/7 "2020-01-21T20:22:15Z")

</div>

I just tried a few variations of the following, with no luck. -

```
round({Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6], 2)
```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [January 21, 2020, 9:08pm UTC](https://forum.inductiveautomation.com/t/rootcontainer-custom-property-type-for-mysql-decimal-5-2/31486/8 "2020-01-21T21:08:06Z")

</div>

I somehow got this to work. I thought for sure I had already attempted this combination but it appears to be functioning like we wanted.

db Table column type is Decimal(5,2)  
Root Container Custom Property id set to type DOUBLE.  
Root Container Custom Property, id Expression Binding

```
try({Root Container.PM Power Table.data}[{Root Container.PM Power Table.selectedRow}, 6], 101.12)
```
