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

**URL:** <https://forum.inductiveautomation.com/t/is-possible-to-get-an-average-value-from-a-power-table-rows/31907>\
**Category:** Ignition\
**Created:** [February 4, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/is-possible-to-get-an-average-value-from-a-power-table-rows/31907 "2020-02-04T15:52:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis1021](https://avatars.discourse-cdn.com/v4/letter/l/9de053/32.png) [@luis1021](https://forum.inductiveautomation.com/u/luis1021)\
**Post date:** [February 4, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/is-possible-to-get-an-average-value-from-a-power-table-rows/31907/1 "2020-02-04T15:52:28Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![bvaldovinos](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bvaldovinos/32/6315_2.png) [@bvaldovinos](https://forum.inductiveautomation.com/u/bvaldovinos)\
**Post date:** [February 4, 2020, 5:07pm UTC](https://forum.inductiveautomation.com/t/is-possible-to-get-an-average-value-from-a-power-table-rows/31907/2 "2020-02-04T17:07:34Z")

</div>

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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![luis1021](https://avatars.discourse-cdn.com/v4/letter/l/9de053/32.png) [@luis1021](https://forum.inductiveautomation.com/u/luis1021)\
**Post date:** [February 4, 2020, 7:39pm UTC](https://forum.inductiveautomation.com/t/is-possible-to-get-an-average-value-from-a-power-table-rows/31907/3 "2020-02-04T19:39:23Z")

</div>

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!
