# Canvas Table subtotals

**URL:** <https://discuss.elastic.co/t/canvas-table-subtotals/293359>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [January 3, 2022, 2:36pm UTC](https://discuss.elastic.co/t/canvas-table-subtotals/293359 "2022-01-03T14:36:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MTV](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@MTV](https://discuss.elastic.co/u/MTV)\
**Post date:** [January 3, 2022, 2:36pm UTC](https://discuss.elastic.co/t/canvas-table-subtotals/293359/1 "2022-01-03T14:36:51Z")

</div>

Hi!

I am trying to calculate subtotals in a table in canvas. Something like this (using the demodata):

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/8/687286be98960b950e41d510d60bdd9bdc25e914.png)

Using the code:

```auto
demodata 
| mapColumn name="year" expression={getCell "time" | formatdate "YYYY"} 
| ply by="year" by="state" expression={math "sum(price)"}
| table
| render

```

At the end, I want to add another column with percentages, where the calculation would be each row for 2019 divided by the 2019 total (repeating for other years). I tried to calculate another column using ply to get the sum of price (keeping all other fields) but it turns out to be null all the time.

This type of calculation is something that I can do in canvas? Or only static columns that give me the total per column are allowed?

Thanks for any help!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 31, 2022, 2:37pm UTC](https://discuss.elastic.co/t/canvas-table-subtotals/293359/2 "2022-01-31T14:37:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
