# EasyGraph sql where clause dynamic

**URL:** <https://forum.inductiveautomation.com/t/easygraph-sql-where-clause-dynamic/111460>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [October 14, 2025, 9:13pm UTC](https://forum.inductiveautomation.com/t/easygraph-sql-where-clause-dynamic/111460 "2025-10-14T21:13:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alfredo\_Egmo](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alfredo\_Egmo](https://forum.inductiveautomation.com/u/Alfredo_Egmo)\
**Post date:** [October 14, 2025, 9:13pm UTC](https://forum.inductiveautomation.com/t/easygraph-sql-where-clause-dynamic/111460/1 "2025-10-14T21:13:58Z")

</div>

I have an EasyGraph, is there a way to change the WHERE CLAUSE from a Button-Script?

thanks

 ![{551CEA44-D72F-4109-97D1-49600D9B42E9}](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/a/eab03abd3e5fa41f65b2571e5226fdc350bbc05c.png)

---

<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:** [October 14, 2025, 9:18pm UTC](https://forum.inductiveautomation.com/t/easygraph-sql-where-clause-dynamic/111460/2 "2025-10-14T21:18:29Z")

</div>

Yes, regenerate the `pens` dataset with a script. (Typically with [system.dataset.setValue()](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-dataset/system-dataset-setValue).)

---

<div class="post-metadata">

**Author:** ![Alfredo\_Egmo](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alfredo\_Egmo](https://forum.inductiveautomation.com/u/Alfredo_Egmo)\
**Post date:** [October 15, 2025, 2:47pm UTC](https://forum.inductiveautomation.com/t/easygraph-sql-where-clause-dynamic/111460/3 "2025-10-15T14:47:43Z")

</div>

If someone Need the code just to replace where clause in an specific DB pen ,in this case row 1 col 16 (which is the WHERE clause.)

```python
chart = event.source.parent.getComponent('Easy ChartT')
tagPenDataSet = chart.pens
#print "Row Count = ", tagPenDataSet.rowCount, " Column Count = ", tagPenDataSet.columnCount,"\n"

newWhereClause = "Equip_ID = '221' and Wireline = '1'"

originalData = system.dataset.toPyDataSet(tagPenDataSet)
newData = system.dataset.setValue(originalData, 1, 16, newWhereClause)
chart.pens = newData

```
