Math functions in power table

how do I divide two columns and put the answer in another column in an power table? This is what I have tried.

if colName == "% of FLA":
		data.getValueAt(rowIndex,"Amps" )/data.getValueAt (rowIndex,"FLA")

This kind of looks like you have this script in the configureCell extension funciton, which isn’t where you want to do this calculation. Where is the data for this table coming from? If it is a db query, is it triggered manually, or do you have a polling rate?

all the data is manually entered except the amps column which is done with cell update binding

If you are manually entering the FLA portion, then you could use a onCellEdited extension function.

if newValue:
	data =
	flaPercentage = data.getValueAt(rowIndex,"Amps" ) / newValue
	newData = system.dataset.setValue(data, rowIndex, '% of FLA', flaPercentage) = newData

sorry, it only gets entered in when I set the table up manually. It will always stay the same.

Yeah I wasn’t thinking right, you want the % col to update as the Amps col updates…

if event.propertyName == 'data':
	data =
	pyData= system.dataset.toPyDataSet(data)
	header = ['Amps','FLA','% of FLA']
	newData = []
	for row in pyData:
		amps = row['Amps']
		fla = row['FLA']
		newRow = [amps,fla, amps / fla]
		newData.append(newRow) = system.dataset.toDataSet(header,newData)

‘A’ or ‘ampere’ or ‘amps’. SI units named after a person are lowercase when spelt out!
The symbols have their first letter capitalised (‘A’, ‘V’, ‘Hz’, ‘Pa’ etc.)

What is the pyData in this example?

I have a Power Table where I’d like to divide the actual column by the target column.

The Power Table obtains data through an SQL Query. Ignition support pointed me to this thread, but it’s not clear how I enter the configureCell script to divide the actual by the target in a new column. Thank you.

Why not do the division in your query instead of a script?

pseudo SQL

select actual, target, round(actual/target,3) as percentage
from <your_table>
where ...

This is how I am doing it, the data I am using is just typed in except the amps column which I use a cell update binding

	from java.awt import Font
        #Table data
	data =		
	returnValue = {}	

	#% of FLA
	if (colName == '% of FLA'):
		col1 =, "FLA")
		col2 =, "Amps")
		if col2:
			col3 = int(100*(col2/col1))
			return {'text': col3}

Thank you. I found another way to get the data I needed so I didn’t have to do math after all.

Thank you, that’s so much easier than what I was trying!

1 Like