# Scripting for filtering a power table using a text box

**URL:** <https://forum.inductiveautomation.com/t/scripting-for-filtering-a-power-table-using-a-text-box/100941>\
**Category:** General Discussion\
**Tags:** vision, scripting\
**Created:** [January 15, 2025, 7:26pm UTC](https://forum.inductiveautomation.com/t/scripting-for-filtering-a-power-table-using-a-text-box/100941 "2025-01-15T19:26:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnny.1](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johnny.1](https://forum.inductiveautomation.com/u/johnny.1)\
**Post date:** [January 15, 2025, 7:26pm UTC](https://forum.inductiveautomation.com/t/scripting-for-filtering-a-power-table-using-a-text-box/100941/1 "2025-01-15T19:26:11Z")

</div>

Hi guys, Im just wondering my filter or my script is not working when i call it. So im just wondering what i can do to fix this or maybe improve it. Please and thank you.

```python

def filterPowerTable(ds, textValue):
    """
    filters a dataset based on the ID column matching the text input value.
    
    Example:
        filtered = filterPowerTable(ds, textValue="12345")
    
    Arguments:
        ds: The dataset to filter.
        textValue: The value entered in the text input.
    """
    pds = system.dataset.toPyDataSet(ds)
    output = []
    
    for row in pds:
        if all(row["ID"] == value in (textValue)):  
            output.append(row)
    
    return system.dataset.toDataSet(list(ds.columnNames), output)

```

And for my code call in the text propertyChange:

```python

textValue = system.util.getProperty(text)  
ds = event.source.parent.getComponent('powertable')  
    
filtered = WWB.Utilities.dataset.filterPowerTable(ds, textValue)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/2964ee92010b62f521316e71cefed7940fe2cbe0.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 15, 2025, 7:32pm UTC](https://forum.inductiveautomation.com/t/scripting-for-filtering-a-power-table-using-a-text-box/100941/2 "2025-01-15T19:32:37Z")

</div>

I fixed your code formatting; you have to use three 'backticks', `, not single quotes.

The most immediate problem I see is the property change event:

1. **Never** use a `propertyChange` event in Vision that's not immediately filtering which property it cares about, as the first line:

```python
if event.propertyName == "textValue":

```

2. `system.util.getProperty` is not doing what you think it's doing; it's retrieving the value of an overall "system property" for the entire client/designer process, not the property of an individual component. Use the chain-like ⛓ icon in the top right of the script editor to select the property you care about. You should have a path like `event.source.textValue` - reading properties from components is as simple as that.
3. Even if everything else you were doing was working the way you wanted it to - you're running your `filterPowerTable` function, and returning a new result, and even assigning that result to a new variable...but you're not assigning it _back to the component_. You need a final line like:

```python
event.source.parent.getComponent("powertable").data = filtered

```
