Is possible to get an average value from a Power Table rows

Hi,

I’m new here and need some help with a power table. I create a power table with 3 rows and 13 columns and the main idea is to get an average value between row 0 and row 1 and get the value for display in row 3 for each column. It is possible? Thanks in advance!

This will work if you put a button on the window where the Power Table is. It’s not the best or most pythonic way to do things but it works.

ds = event.source.parent.getComponent('Power Table').data
pyDS = system.dataset.toPyDataSet( ds )
headers = system.dataset.getColumnHeaders(ds)

rowCount = ds.getRowCount()
colCount = ds.getColumnCount()
#print rowCount, colCount

for x in range(colCount):
	rowOneValue = ds.getValueAt(0, x)
	rowTwoValue = ds.getValueAt(1, x)
	average = (rowOneValue + rowTwoValue) / 2.0
	print "Average: " + str(average)
	print "Header: " + headers[x]
	newDataset = system.dataset.setValue(event.source.parent.getComponent('Power Table').data , 2, headers[x] , average)
	event.source.parent.getComponent('Power Table').data = newDataset

Thanks bvaldovinos!! works great the way I need it. I get the values from the instrument interface so I write the script in the “onReceive” event handler. That way the button is not need it. Thank You!

1 Like