Select row and then filter table by value from a column in that row

Ok so I’m pretty new to scripting in Python and I’m having trouble figuring this one out.

I have a table full of results and every row has a barcode (stored as a string) included. I’d like to be able to open a popup menu on a selected row and then take the barcode value of that row and then filter the table by that value. I’m just completely lost on how I need to structure this event.

Any help or guidance?

Basically something like this

tbl = event.source.parent.getComponent('Power Table')
pDS = system.dataset.toPyDataSet(event.source.parent.getComponent('Power Table').data)
hdr = list(event.source.parent.getComponent('Power Table').data.getColumnNames())
flt =,'BarCodeColumn')
filtered = []
for row in pDS:
	if row['ColumnToCompareTo']==flt:
event.source.parent.getComponent('Power Table').data=system.dataset.toDataSet(hdr,filtered)

Ok this is what I eventually got to work and it does what I want.

 def filter(event)
	pDS = system.dataset.toPyDataSet(
	hdr = list(pDS.getColumnNames())
	flt =, 'Barcode')
	filtered = []
	for row in pDS:
		if row['Barcode']==flt:
			filtered.append(list(row)) = system.dataset.toDataSet(hdr,filtered)

menu = system.gui.createPopupMenu(['Isolate Barcode'], [filter])

However, I have the Power bound to a Named Query in polling mode. This means that when that poll is executed, the query overwrites my new dataset. Is there a way to manipulate the column filtering directly through scripting?