Retrieving maximum value from dataset in easy chart 8.1


I’ve got an easy chart which retrieves data based on the tags and time span selected by user. From the data retrieved I’d like to display the maximum value (and the average if possible) of a particular tag (the chart displays 4 tags).

I’m using the following code:

#get values from temperature for maximum and average
if event.propertyName in ('startDate', 'endDate'):
	startDate = event.source.startDate
	endDate = event.source.endDate
	tagPath= '[default]Retort 1/Retort 1 Temperature'
	Max = system.tag.queryTagHistory(paths= [tagPath],
#	Avg = system.tag.queryTagHistory(paths= [tagPath],
#		startDate=startDate,
#	   	endDate=endDate,
#	   	returnSize=100,
#	   	aggregationMode='Basic Average')
	event.source.parent.getComponent('Max').value = Max
#	event.source.parent.getComponent('Avg').value = Avg

When I test my display, I get an error

TypeError: can’t convert Dataset [1R ⅹ 2C] to double

I use similar scripting to calculate volumes, and don’t get these same convert errors. Is there some way to change the Numeric display to not require a double integer (tag uses integer values)? Some other way to just get the maximum value from that dataset?

system.tag.queryTagHistory returns a dataset per the docs system.tag.queryTagHistory - Ignition User Manual 8.0 - Ignition Documentation
would think right here -
event.source.parent.getComponent('Max').value = Max is the problematic line that your Max components property value is expecting a double but you are giving it a dataset.

You should be giving it Max.getValueAt(0,1) (note you get two columns back, the first one is always a timestamp).


Thanks, that’s exactly what I had missed, the returned dataset had non-numeric values. Thanks again!!

1 Like