# Toggle filter for query used by table component

**URL:** <https://forum.inductiveautomation.com/t/toggle-filter-for-query-used-by-table-component/4063>\
**Category:** Ignition\
**Created:** [February 24, 2012, 8:34pm UTC](https://forum.inductiveautomation.com/t/toggle-filter-for-query-used-by-table-component/4063 "2012-02-24T20:34:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [February 24, 2012, 8:34pm UTC](https://forum.inductiveautomation.com/t/toggle-filter-for-query-used-by-table-component/4063/1 "2012-02-24T20:34:07Z")

</div>

Let’s say I have some filters for Name, UserID and Daterange (two popup calendars). I also have some check box components I want to use to enable/disable these filters. I have a table to display the resulting dataset. I can write the sql so that it resolves any of the above in the where clause.

How can I dynamically change my sql statement when I toggle the check boxes on or off?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [February 24, 2012, 9:53pm UTC](https://forum.inductiveautomation.com/t/toggle-filter-for-query-used-by-table-component/4063/2 "2012-02-24T21:53:40Z")

</div>

What I typically do is add a dynamic property called whereClause that is a string to your filter components. Bind the property to an expression like:`if({Root Container.Check Box.selected}, "Something = '" + {Root Container.Comp.text} + "'", "1=1"}`You would then add these properties to your SQL query in the where clause:`SELECT 
    ....
FROM 
    Table
WHERE
    {Root Container.Comp.whereClause} AND 
   {Root Container.Comp 2.whereClause}`

---

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [February 27, 2012, 4:25pm UTC](https://forum.inductiveautomation.com/t/toggle-filter-for-query-used-by-table-component/4063/3 "2012-02-27T16:25:47Z")

</div>

Thank you.
