[PRO] Column Summaries based on applied filter

Tags: #<Tag:0x00007efc728c5cd8>

Hello!

We are trying to combine filters and summary calculations, which doesn’t seem to work.
Imagine following table data:

NAME…| VALUE

PersonA | 10
PersonA | 20
PersonB | 15
PersonA | 30

Now we already successfully added an empty fixed row to the bottom which holds the columnSummary calculated data.
Using: destinationRow: 0, destinationColumn: 1, reversedRowCoords: true, type: 'sum', forceNumeric: true

This works fine and gives us the following result:

NAME…| VALUE

PersonA | 10
PersonA | 20
PersonB | 15
PersonA | 30
…| 75

However, as soon as the user applies a filter on the first column e.g. choosing only “PersonA”, the summary results disappear. But what the user would expect and what we would like to have is a summary caluculation based on the applied filter:

FILTER: PersonA
PersonA | 10
PersonA | 20
PersonA | 30
…| 60

How can we accomplish this?

Thank you!

Hi @onelogic
I’ve made a demo of the following: http://jsfiddle.net/u8m7gbv3/

So the action is to filter out the PersonB and get updated sum

But currently filtering only hides rows that is why the calculation still returns 75. It will also work the same while using formulas: http://jsfiddle.net/os4gknh4/

If your data is not very complicated you can use setDataAtCell() method to get updated value. To get indexes of trimmed rows (those that were hidden via filtering process) you should use the following line:

instance_name.getPlugin('trimRows').trimmedRows;

this will return an array of trimmed rows. If filters are not applied the following line returns an empty array.

I think that users should have a choice to set if they want to update the results so I’m addinf the improvement suggestion label for this topic. Thank you very much for suggesting @onelogic

Thank you @aleksandra_budnik for the fast response.

What I really would like, is a fixed summary row at the bottom of the table, which is not part of the data it self.
So that the shown summary calculations are always caluculated by the current data visible to the user.
I am sure there would be a lot of use cases for such a feature. :slight_smile:

I agree @onelogic
actually we have the same issue as you described on our internal ticketing system. Summary calculations row should not be counted to the data like rest of the cells.

Hi @aleksandra_budnik !

Is there any update on this? :slight_smile:
Thank you and keep up the good work!

Hi @onelogic

Thanks for your effort to track this issue.

Currently our programming power is focused on two big dead-lines are we won’t be able to fix any non high priority cases till late January.

Thanks for the update!

You’re welcome @onelogic
I would rather want to share more optimistic news however I am currently gathering all issues that will be used to create a new Roadmap for 2017. If the team would decide that we need to fix anything related to this task in Q1 I’ll come back with news.

Is there any update on this? Is this doable with the current version on HandsOnTable?

Hi @rakesh.mishra if you mean the quotes issue it if still unsolved.

Hi,
Are there any updates regarding column summaries being aware of the current filter state?

Is it possible to configure columnSummary plugin to take into account the trimmed rows?

If not, what is the suggested practice of extending ColumnSummary plugin to create a custom ColumnSummary plugin?

I do not see any other columnSummaries + filtering on the Github board. However the summaries themselves does not work well if the data updates https://github.com/handsontable/handsontable/issues?q=is%3Aopen+is%3Aissue+label%3A"PRO%3A+summary+calc" so it might be a problem to count trimmed data as well. But I think that you can use the native methods - here’s a demo https://jsfiddle.net/8n7v9w4r/