# Table selection, filters problem and bugs

**URL:** <https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 4, 2023, 3:59pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896 "2023-07-04T15:59:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaloyan\_Radomirov](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kaloyan\_Radomirov](https://forum.inductiveautomation.com/u/Kaloyan_Radomirov)\
**Post date:** [July 4, 2023, 3:59pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/1 "2023-07-04T15:59:28Z")

</div>

Hello guys  
I have a problem with calculation the total of a filtered column.  
When I write something in the filter (search bar) of the table  
the results are out and I can have an amount.  
If I also apply a column filter after that, everything is ok.  
But if I apply only a column filter without typing in the search bar, the selected data does not appear anywhere.  
The filtered rows appear visually, but not the data

I have a change script in a filter.data-\> self.refreshBinding("props.columns[2].footer.title")

There are another bugs:

1. When I use preview mode in designer, the text in the search bar appears in the client sessions and the client table gets messed up.

2. Same with the dropdown when I select something in designer preview mode in the dropdown that appears in client sessions and it stays if I don't delete it from the designer.

3. If I have a applied column filter in one session it appears in a others sessions.

I don't use any associated tags, everythings is _'self.props'_

 ![table](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/e/de70093fd49e09dcd2f1c82b28f245d7052a47d1.png)  
 ![t2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6fde0c604cfac330fd899be483baeabc150b9ca1.png)  
 ![t3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/a/3a44df8b1e2dac3c997972a35f2d183e27b55eac.png)  
 ![footer code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b267bb2d53445c17c259bccede9304eb3b69866c.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 4, 2023, 4:54pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/2 "2023-07-04T16:54:29Z")

</div>

I don't understand the problem, can you try describing the issue in french ?

As for the script, I'll suggest this:

```python
def transform(self, value, quality, timestamp):
	val = self.props.filter.results.data
	if not val:
		val = self.props.data
	q = sum(v['poids'] for v in val)
	return "Total: {} Kg".format(round(q, 3))

```

It should do the same thing, but I didn't try it so there might be typos/syntax errors.

---

<div class="post-metadata">

**Author:** ![Kaloyan\_Radomirov](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kaloyan\_Radomirov](https://forum.inductiveautomation.com/u/Kaloyan_Radomirov)\
**Post date:** [July 4, 2023, 4:58pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/3 "2023-07-04T16:58:57Z")

</div>

the problem is not in the script.  
yours do the same job.

When I write something in the filter (search bar) of the table  
the results are out and I can have an amount from _'self.props.filter.results.data'_  
If I also apply a column filter (see pic.1) after that _'self.props.filter.results.data'_ updates and result is ok.

But if **I apply only a column filter without typing in the search bar** , the selected data does not appear anywhere.  
The **filtered rows appear visually,** but not the data changed in a _'self.props.filter.results.data'_

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 4, 2023, 5:20pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/4 "2023-07-04T17:20:55Z")

</div>

Column filters are relatively new, they might still be a bit buggy.  
Either wait for more advice on this, or contact support.

> [@Kaloyan\_Radomirov](#):
>
> the problem is not in the script.  
> yours do the same job.

I know, I did say "It should do the same thing".  
It's just cleaner and more efficient.

---

<div class="post-metadata">

**Author:** ![Kaloyan\_Radomirov](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kaloyan\_Radomirov](https://forum.inductiveautomation.com/u/Kaloyan_Radomirov)\
**Post date:** [July 4, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/5 "2023-07-04T17:26:11Z")

</div>

_'It's just cleaner and more efficient.'_

Тhanks, that's not the topic.  
Tell about other bugs, pls.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 4, 2023, 5:35pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/6 "2023-07-04T17:35:35Z")

</div>

If you're going to take it like this, no thanks and good luck.

---

<div class="post-metadata">

**Author:** ![Kaloyan\_Radomirov](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kaloyan\_Radomirov](https://forum.inductiveautomation.com/u/Kaloyan_Radomirov)\
**Post date:** [July 4, 2023, 5:38pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/7 "2023-07-04T17:38:48Z")

</div>

Bye master.

I rework and optimize the code before releasing the project, this is the final stage.  
Before that, I write without thinking maybe 10 times different code in the fastest way possible for me.  
Be helpful, not talkative, this is not a Python course.

---

<div class="post-metadata">

**Author:** ![eMax](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@eMax](https://forum.inductiveautomation.com/u/eMax)\
**Post date:** [September 23, 2023, 2:33pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/8 "2023-09-23T14:33:01Z")

</div>

Hello Sir.  
I have a similar problem.  
I'm trying to sum the values of a column and put the result at the bottom in the footer.  
I tried to use your code, I don't know Python well (I'm from .NET)...  
my goal (if possible), is to update the total of the 'Quantity' column in the footer in "real time" (as I type in the table filter).  
This is what I've done so far...  
Thank you in advance if you have any suggestions.

 ![props](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/1/a1cf11fb4d6bc82a1961aeeedc61e78cdfd353a5.jpeg)  
 ![script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6cbcd1aca59d5da7b67b3249e5f1b99987a29ce7.jpeg)  
 ![error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/81eaf506356e8b1dde6a169d0a9d2b341fde93f1.jpeg)

---

<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:** [September 23, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/9 "2023-09-23T14:37:02Z")

</div>

I think you should ask a new question. @pascal.fragnoud dropped out of this one due to the rudeness of the OP. (Pascal is one of the really helpful users on the site and has made about 2,200 posts.) He is unlikely to respond on this thread so delete your post here and ask a new one.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 23, 2023, 2:52pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/10 "2023-09-23T14:52:05Z")

</div>

I don’t mind answering to polite people, wherever it is.  
@eMax I’m on a phone right now so it’s not an ideal situation to give you pointers, I’ll try and remember to come back to this when I have a designer available.  
I’m the meantime, just to make things extra clear: you want to update the footer in real time with the sum of the values in the column, using only the values that were not filtered out. It’s that correct ?

---

<div class="post-metadata">

**Author:** ![eMax](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@eMax](https://forum.inductiveautomation.com/u/eMax)\
**Post date:** [September 23, 2023, 4:14pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/11 "2023-09-23T16:14:29Z")

</div>

yes, that's correct  
@Transistor, you were right, I had to ask a new question.  
This is my first question ever on this forum.  
I wrote directly to mr. Fragnoud because I've seen this "problem" is quite similar to mine

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 23, 2023, 4:59pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/12 "2023-09-23T16:59:18Z")

</div>

Alright, so the setup I used first:

- `prop.filter` enabled
- `prop.filter.results` enabled
- footer enabled
- explicitly defined columns in the `columns` prop
- property binding on the "quantita" column's `footer.title`, bound to `props.filter.results.data`
- script transform on this binding with this code:

```python
data = value if value else self.props.data
s = sum(v['population'] for v in data)
return "total: {}".format(s)

```

BUT !  
This works for tables with json formatted data.  
It seems your table is using a dataset, which is not iterable in the same way, and that's why the script fails. Since it fails, it returns `null`, and this leads to the second error as the `title` property of the footer expects a string.

For datasets, you can use this transform instead:

```python
if value:
    total = sum(v['quantita'] for v in value)
else:
    col_index = self.props.data.getColumnIndex("quantita")
    total = sum(self.props.data.getColumnAsList(col_index))
return "total: {} Kg".format(round(total, 0))

```

---

<div class="post-metadata">

**Author:** ![eMax](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@eMax](https://forum.inductiveautomation.com/u/eMax)\
**Post date:** [September 23, 2023, 6:25pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/13 "2023-09-23T18:25:50Z")

</div>

wow, that's great!  
it works almost as expected.  
By the way, in this case, json works better than dataset.  
The only "bug" is that the total at first (when page opens) shows "0" and total is not populated until I write something in the filter.  
You put me on the right path!  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 23, 2023, 7:05pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/14 "2023-09-23T19:05:17Z")

</div>

Right, an oversight on my part.  
To fix this, use a structure binding instead of a property binding, in which you'll create 2 elements, one bound to `props.data` and the other one to `props.filter.results.data`.  
Then use those values in the transform:

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

script for datasets:

```python
if value.filtered:
    total = sum(v['qty'] for v in value.filtered)
else:
    col_index = value.data.getColumnIndex("qty")
    total = sum(value.data.getColumnAsList(col_index))
return "total: {} Kg".format(round(total, 0))

```

for json:

```python
data = value.filtered if value.filtered else value.data
total = round(sum(v['population'] for v in data), 0)
return "total: {}".format(total)

```

---

<div class="post-metadata">

**Author:** ![eMax](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@eMax](https://forum.inductiveautomation.com/u/eMax)\
**Post date:** [September 23, 2023, 7:46pm UTC](https://forum.inductiveautomation.com/t/table-selection-filters-problem-and-bugs/75896/15 "2023-09-23T19:46:12Z")

</div>

Thank you @pascal.fragnoud!  
Everything works fine, you saved my day.

Have a nice evening.
