# Filtering a table with Named Querie with 3 checkboxes in Ignition Perspective

**URL:** <https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 24, 2024, 10:35am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345 "2024-04-24T10:35:07Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 10:35am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/1 "2024-04-24T10:35:07Z")

</div>

Hello!

I would like to filter a table with 3 checkboxes, depending on wich checkbox I choose the content of the table is filtered.  
Each checkbox corresponds to a possible value in one of the table's columns.

Is posible do this with bindings or is better with a script in Phyton.

Cheers

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 10:44am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/2 "2024-04-24T10:44:56Z")

</div>

Do you know about the table's built-in column features?  
`columns.n.filter.enabled : true`  
There are other options in columns.n.filter as well.

Show your dataset and explain your checkboxes.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 10:56am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/3 "2024-04-24T10:56:26Z")

</div>

I didn´t know about the columns.n.filter.enabled : true

Now I changing it:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2a53d8f92977cfdea280a06e0eb112192d552b4c.png)

This is the part of the named query that show column ESTADO in my table

```python
  (CASE 
    WHEN WORKREQUESTSTATE='00' THEN 'Pendiente'
    WHEN WORKREQUESTSTATE IN ('10','20') THEN 'Generada OT'
    WHEN WORKREQUESTSTATE='30' THEN 'Rechazada'
    ELSE 'Estado Desconocido'
  END) AS ESTADO

```

This are the 3 checkboxes:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7e3ef7d33f8cc58c5e5e277f31984af6c10246ba.png)

Checkboxes and table are in the same Column Container

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 11:06am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/4 "2024-04-24T11:06:06Z")

</div>

So, you have a table of data where one column is ESTADO (status) and you want the checkboxes to enable display of one or more ESTADO conditions?

| Checkbox | Result |
| --- | --- |
| None | Show only Estado Desconocido. |
| Pendiente : true | Include Pendiente. |
| Generada OT : true | Include Generada OT. |
| Rechazada : true | Include Rechasada. |

Is this correct?

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 11:06am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/5 "2024-04-24T11:06:48Z")

</div>

None option should show all the rows

the rest is ok

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 11:10am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/6 "2024-04-24T11:10:47Z")

</div>

> [@Alejandro\_Alaco](#):
>
> None option should show all the rows

Bad idea.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 11:11am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/7 "2024-04-24T11:11:33Z")

</div>

Ok, then the other way around would be fine, the way you tought

| Checkbox | Result |
| --- | --- |
| None | Show only Estado Desconocido. |
| Pendiente : true | Include Pendiente. |
| Generada OT : true | Include Generada OT. |
| Rechazada : true | Include Rechasada. |

would need to have all checkboxes selected from begining

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 11:57am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/8 "2024-04-24T11:57:30Z")

</div>

We will return all the records to a custom property. Then we will use a script to display only the records of interest. This means that we only query the database once.

1. On the table, create a custom property, `custom.data`.
2. Put your query binding on that.
3. On the table `data` property configure like this:  
 ![ESTADO script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78b6ec0329898d16bc0e545f0819f45156e73da4.png)

> **The script transform.**
>
> ```python
> def transform(self, value, quality, timestamp):
> output = []
> for row in value['data']:
> if value['chkPend']:
> if row['ESTADO'] == 'Pendiente':
> output.append(row)
> continue
> if value['chkGene']:
> if row['ESTADO'] == 'Generada OT':
> output.append(row)
> continue			
> if value['chkRech']:
> if row['ESTADO'] == 'Rechasada':
> output.append(row)
> continue			
> if row['ESTADO'] == 'Estado Desconocido':
> output.append(row)
> 			
> return output
> 
> ```

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 2:31pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/9 "2024-04-24T14:31:11Z")

</div>

Following your instructions but seem something not working right:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1a926de077af931293e1963460741503f1257283.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/c/fc55884f0c941f5e06905210e70fcb1f64c433e4.png)

Maybe is not clear where the error is, cheers.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 2:34pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/10 "2024-04-24T14:34:49Z")

</div>

![Query filter](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/6/961e478197a242aab9e4f093a55c957ec07c0d5a.png)

Edit your Prueba-13 named query and remove the filter parameter. You want it to return all the records. The script will do the filtering.

Wait: is that a different radio group or the filter radio group?  
In your screenshot you have cut off the preview. What is the result of the query?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 2:43pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/12 "2024-04-24T14:43:34Z")

</div>

Sorry, I forgot to tell you to set the query Return Format to JSON (which is what the script is expecting).

 ![Return format JSON](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8ff2965e043a46c560d8da17826dfd4fda2db38e.png)

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 2:49pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/13 "2024-04-24T14:49:14Z")

</div>

This part of the custom.data is working fine now

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/09585430c142e61e441096347d51439662af3b42.png)

the part of the expression on the table.data seem to have an error

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

maybe this helps:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/bab6a3e14cd7810b5695a5141eb0243699cac409.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 2:54pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/14 "2024-04-24T14:54:38Z")

</div>

See post #12.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 3:03pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/15 "2024-04-24T15:03:59Z")

</div>

Wow, working great!, thanks Transistor.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/80f711101d3cdbc60b0b250bd3f4775ae7a3a867.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a64c9256969596ad31c96de81580a4d6a732259e.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbd195f86fdf1ab6f98b82bdaf2bf03b189648f0.png)

Now I will try to start with all checkboxes selected and add the radio button filter we did yesterday.

Cheers.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 24, 2024, 3:13pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/16 "2024-04-24T15:13:23Z")

</div>

Ok, just added the radio button filter as you teach me yesterday in the custom.data binding and both are working fine together.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/095bcbbdd1617c375c8f94b814cf371a8747a105.png)

Thanks

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 24, 2024, 3:45pm UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/17 "2024-04-24T15:45:15Z")

</div>

Good work.

Suggestion: I think your full-cell color is too much and black on red is never good. Here's a trick:  
Modify the style and set the left border to 20 px and add some color there instead. You get a nice indicator with an easy-to-read text beside it. There is no need to "scream" color! Be cool, man! Be cool!

![Subtle color indicator](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e7cd9e86f2b2bc0d19a9fd6a7f7121f7b7a0e47.png)

You need to do this for each different style that you use.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 25, 2024, 7:08am UTC](https://forum.inductiveautomation.com/t/filtering-a-table-with-named-querie-with-3-checkboxes-in-ignition-perspective/89345/18 "2024-04-25T07:08:19Z")

</div>

Thanks for the advice! just implemented it.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/d/9d4f9474d22708565bf829a0347506d885f328d3.png)
