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

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

property binding.

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

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

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)

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:

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

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)

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)

1 Like

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)

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)