# Add total row in Canvas Datatable

**URL:** <https://discuss.elastic.co/t/add-total-row-in-canvas-datatable/315144>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [September 26, 2022, 8:31am UTC](https://discuss.elastic.co/t/add-total-row-in-canvas-datatable/315144 "2022-09-26T08:31:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chiaaa](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@Chiaaa](https://discuss.elastic.co/u/Chiaaa)\
**Post date:** [September 26, 2022, 8:31am UTC](https://discuss.elastic.co/t/add-total-row-in-canvas-datatable/315144/1 "2022-09-26T08:31:58Z")

</div>

Hi everyone,

I have a question: I need to add a line with totals on my Canvas datatable.  
It's possibile ?  
I created in Canvas a table with ES SQL Query and I cannot import Table object from Kibana, because in Canvas I have the possibility to create calculated column and add graphic customization... but I don't know how to add in my table a row with the columns totals.

I'll appreciate any suggestion.  
Thanks,  
Chiara

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [September 26, 2022, 12:12pm UTC](https://discuss.elastic.co/t/add-total-row-in-canvas-datatable/315144/2 "2022-09-26T12:12:34Z")

</div>

Maybe you could use an expression language to tackle this one? Here's a response with a similar question: [How to create a new line on a kibana canvas table - #4 by wylie](https://discuss.elastic.co/t/how-to-create-a-new-line-on-a-kibana-canvas-table/248179/4)

---

<div class="post-metadata">

**Author:** ![Chiaaa](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@Chiaaa](https://discuss.elastic.co/u/Chiaaa)\
**Post date:** [September 27, 2022, 8:35am UTC](https://discuss.elastic.co/t/add-total-row-in-canvas-datatable/315144/3 "2022-09-27T08:35:36Z")

</div>

Hi @Marta_Bondyra ,

thanks for your reply. I read the post you attached, but I have another question.  
My code is something similar like this:

```auto
var_set name="total" name="results" 
  value={essql "SELECT count(*) as Total FROM \"index-patter-name*\" where ReportDate > dateadd('MM',-1,curdate()) and ReportDate < dateadd('DD',-2,curdate()) "}
  value={essql "select top 10 FieldA as Venue,
count(*) as Volumi2
from \"index-pattern-name*\"
where 
ReportDate >= dateadd('MM',-1,curdate()) and ReportDate <= dateadd('DD',-2,curdate()) and FieldA is not null 
group by FieldA
Order by Volumi2 desc "}
| var name="results"
| var_set name="sum" value={ply expression={math "sum(Volumi2)"} | getCell "value"}
| var name="results"
| mapColumn name="Volumi" fn={getCell "Volumi2" | formatnumber "0,0"}
| staticColumn name="sum" value={var name="sum"}
| mapColumn name="Volumi percentuali" expression={math "Volumi2/sum" | formatnumber "0.00%"}
| sort by="Volumi2" reverse=true
| columns exclude="sum,Volumi2"
| table paginate=false perPage=10 

```

Reading the post, I don't understand how to add row 'Total' in the column Venue ?  
I must create an if condition or something similar for the column Venue ?

Thanks,  
Chiara

---

<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:** [October 25, 2022, 8:36am UTC](https://discuss.elastic.co/t/add-total-row-in-canvas-datatable/315144/4 "2022-10-25T08:36:29Z")

</div>

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