Summing column values in selected rows

I have a power table that updates from a database. I am able to Sum the total column value by binding the value of my numeric label to SUM({Root Container.GS},4).

How can I get a value for the sum of the current selection in that column?

I.E. I want to allow the operator to select, say, 10 rows out of the table, and a numeric label to correctly populate the sum of the values in Column 4 of only those selected 10 rows.

On the Power Table, if you go to it’s scripting methods and enable its onMouseClick() extension function you can do a simple script like:

	columnToSum = 1 # This is the column you want to start summing
	sum = 0
	for row in self.selectedRows:	# self.selectedRows is an array of the currently selected rows
		sum +=,columnToSum)
	self.parent.getComponent('Numeric Label').value = sum # Set this sum to the value of the numeric label

I think this has an indentation error. When I fix that, I get a value of 0 regardless of the values in that column.

Ok. I was putting this code in the MouseClicked Event Handler rather than the onMousePress extension function. That was my problem.
Now, in order for the numeric label to update properly, I need to highlight the rows I was to sum, and then let go and click on the table again.

This should suffice.
Thank You.

If you use the onMouseClick() extension function instead of the onMousePress() extension function you shouldn’t have to click the table again after selecting some rows.