Filter in table

Hi,

I am using the Tag Historian option to log the data. On the Table, using Tag History binding, we can able to show the logged data. I need to add a filter which needs to works like ‘WHERE’ clause in SQL query.

Like the table should data of Particular column = ‘Some Value’.

Thanks in Advance!!

The tag historian doesn’t offer that feature built-in. You will need to move the binding to a custom property and perform the filtering action yourself. You can do this with a script, but for convenience I recommend the view() expression function from my free Simulation Aids module.

You would bind the original table’s data property with an expression like this:

view("Select * Where someColumn==someConstant", {Root Container.path.to.custom.prop})

Hi Pturmel,

Thanks for the reply!!.

Can you please write here some pseudo code for filtering a table data?

Thanks in Advance!!.

I have written some code, but it’s not working.

data = event.source.parent.TagHistoryData
data1= event.source.parent.getComponent(‘Power Table’)
row1=0
col1=0

for row in range(data.rowCount):
row1 = row
for col in range(data.columnCount):
col1 = col
value = data.getValueAt(row, col)
if value == event.source.parent.getComponent(‘MouldComboBox’).SelectedText:
system.dataset.addRows(data1.data, row1, value)
newData = system.dataset.setValue(data1.data, row1, col1, value)

event.source.parent.getComponent(‘Power Table’).data = newData

Can someone correct me please?..

Can you please use the preformatted text button when posting code:

code

data = event.source.parent.TagHistoryData
data1= event.source.parent.getComponent('Power Table')
row1=0
col1=0 
 
for row in range(data.rowCount):
   row1 = row
   for col in range(data.columnCount):
      col1 = col
      value = data.getValueAt(row, col)
      if value == event.source.parent.getComponent('MouldComboBox').SelectedText:
      	system.dataset.addRows(data1.data, row1, value)
      	newData = system.dataset.setValue(data1.data, row1, col1, value)
      
event.source.parent.getComponent('Power Table').data = newData
      

Here ‘TagHistoryData’ refers to Root container custom property, which is a dataset binding to Tag History.

Idk what you are all doing here but this seems quite wrong
try this

	data = event.source.parent.TagHistoryData

	newData =  system.dataset.toDataSet(data.getColumnNames().toArray(),[])
	
	for row in range(data.rowCount):  
		newRow = []
		for col in range(data.columnCount):
			value = data.getValueAt(row, col)
			newRow.append(value)
		
		if event.source.parent.getComponent('MouldComboBox').SelectedText in newRow:
			newData = system.dataset.addRow(newData, newRow)
			
	event.source.parent.getComponent('Power Table').data = newData