# Filter in table

**URL:** <https://forum.inductiveautomation.com/t/filter-in-table/53282>\
**Category:** Ignition\
**Created:** [November 19, 2021, 11:15am UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282 "2021-11-19T11:15:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahamed](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@sahamed](https://forum.inductiveautomation.com/u/sahamed)\
**Post date:** [November 19, 2021, 11:15am UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/1 "2021-11-19T11:15:56Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 19, 2021, 1:56pm UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/2 "2021-11-19T13:56:20Z")

</div>

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()](https://www.automation-pros.com/simaids/doc/expression.view.html) expression function from my free [Simulation Aids](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-simulation-aids) module.

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

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

```

---

<div class="post-metadata">

**Author:** ![sahamed](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@sahamed](https://forum.inductiveautomation.com/u/sahamed)\
**Post date:** [November 20, 2021, 6:59am UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/3 "2021-11-20T06:59:55Z")

</div>

Hi Pturmel,

Thanks for the reply!!.

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

Thanks in Advance!!.

---

<div class="post-metadata">

**Author:** ![sahamed](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@sahamed](https://forum.inductiveautomation.com/u/sahamed)\
**Post date:** [November 20, 2021, 8:22am UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/4 "2021-11-20T08:22:53Z")

</div>

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?..

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 20, 2021, 1:49pm UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/5 "2021-11-20T13:49:23Z")

</div>

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

![code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e8f717e3b23194ced28f88b991e2d3113dc308d.png)

---

<div class="post-metadata">

**Author:** ![sahamed](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@sahamed](https://forum.inductiveautomation.com/u/sahamed)\
**Post date:** [November 20, 2021, 2:02pm UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/6 "2021-11-20T14:02:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 22, 2021, 11:31am UTC](https://forum.inductiveautomation.com/t/filter-in-table/53282/8 "2021-11-22T11:31:49Z")

</div>

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

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

```
