How to format a number in a report table

I have a report with two data sources - a static data source and a script data source. There are two columns - a name and a numeric value. They have the same data (within data type constraints).
I have displayed the data in tables. The value column is formatted as#,##0.

The static data is shown as expected - rounded to 0 decimal places and a thousands separator. The calculated data is not formatted.

Ignition 8.1.28

Screenshots (because I don't see a json export)

static_data
Meter, Value
"Static Meter 1", 32191.110980111298
"Static Meter 2", 8.1
script_data
def updateData(data, sample):	
	header = ['Meter', 'Total']
	rows = []
	
	dataset = system.dataset.toDataSet(header, rows)
		
	data['Computed_Totals'] = dataset

	firstValue = 2343.123345234235623434
	secondValue = 34534.234325345534534563453

	total1 = secondValue - firstValue
	newRow = ['Calc Meter 1',total1]
	dataset = system.dataset.addRow(dataset, newRow)	

	total2 = 8.1
	newRow = ['Calc Meter 2',total2]
	dataset = system.dataset.addRow(dataset, newRow)	

	data['Computed_Totals']=dataset

toDataset defaults to string if no more specific type can be inferred from the data. Since you're not specifying a row, your column will be of type string, not a true number.

Just build your dataset last.

1 Like

Thanks.
So when I was displaying type(newRow[1]) that was before the conversion. I should have displayed type(dataset[0][1]) instead.
And total2 = round(8.1, 0) was showing 8.0, so the automatic conversion defaults to one decimal place in that circumstance?