[BUG] Perspective Table number format breaks if first row has null value

This is in Ignition 8.1.2–I don’t have a later version installed yet to confirm whether it applies to them as well.

All of these columns have the same format settings:
The null values in October and November render as blank (great) and the number format is applied with one decimal place as expected. In the December column, the first row has a null value and it renders as null (as well as later nulls in this column) and the number formatting doesn’t get applied to any values in the column. This issues consistently occurs in any column with a null value in the first row (tested with varying datasets).

Column settings:
image image image

I’m guessing this could be worked around via a script transform to replace nulls in first row with something else, but haven’t tried yet. Any other suggestions, or is that the way to go?

Constructing datasets in scripts with system.dataset.toDataSet() ? It uses the first row’s datatype to set the datatypes of the columns. Nulls yield the string datatype by default. You should use the DatasetBuilder helper class instead, which requires/allows you to specify the column types explicitly.

1 Like

Thanks @pturmel. I’ve used DatasetBuilder–I think after a suggestion from you in the past (thanks!). It works great for scripted dataset creation. This is a SQL query binding. It makes sense it’d be relying on default behavior without anything else to go by. This led me to look for any column settings that might be relevant. Changing render from auto as above to number
switched back to displaying nulls as blanks, but numberFormat is still ignored for columns with a null in first row:
Is there a better way to specify column datatype in this case, or is post-processing the data into a new dataset via DatasetBuilder the way to go?

And should I remove the “BUG” prefix on this post, or would it be fair to expect giving the column a render type of number should result in numberFormat being applied to numbers in it in this case. It’s halfway there hiding the nulls!

Hmmm. I’d call it a bug. The Perspective table shouldn’t be making decisions about formatting for all rows from the contents of the first row.

1 Like

Well, in auto it probably does for performance reasons, but agreed that with an explicitly set render mode numberFormat should absolutely be respected.


Hmm, I wonder if this has been fixed since 8.1.2? I’m unable to replicate on 8.1.5, at least in the simplest case:

Even using a dataset, things work as expected:

Thanks for checking @PGriffith . If you want to throw it in version 8.1.5, here’s the same data I’m using (as returned by query binding and copied from dataset editor):

"Month 1","Month 2","Month 3"

It looks like it is defining the column in dataset generated by query binding as string type based on null in first row in 8.1.2. Perhaps 8.1.5 does not do that. If that’s the case, pasting above dataset in won’t be relevant. Or perhaps 8.1.5 overrides the column type in dataset with column render setting. This would seem more likely, and if this is the case number formatting should apply to third column despite initial null.

Yeah, I’m guessing the column data type is playing into things. I’ll take a closer look later today.

1 Like

Hopefully the underlying Perspective Table implementation will handle this in the future for columns with specified types. For now, this script transform does the trick:

	from java.lang import Float
	from com.inductiveautomation.ignition.common.util import DatasetBuilder
	if value is None:
		return value
		# Build new dataset with specified column types.
		colNames = ["Month 1", "Month 2", "Month 3"]
		colTypes = [Float, Float, Float]
		b = DatasetBuilder.newBuilder().colNames(colNames).colTypes(colTypes)
		# Copy original data into new dataset.
		for row in system.dataset.toPyDataSet(value):
			b.addRow(row[x] for x in range(len(row)))
		return b.build()