# Handling an empty datatable

**URL:** https://discuss.elastic.co/t/handling-an-empty-datatable/186963
**Category:** Kibana
**Created:** [June 22, 2019, 4:52pm UTC](https://discuss.elastic.co/t/handling-an-empty-datatable/186963 "2019-06-22T16:52:19Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![gbarnett](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@gbarnett](https://discuss.elastic.co/u/gbarnett)
#### Post date: [June 24, 2019, 2:05am UTC](https://discuss.elastic.co/t/handling-an-empty-datatable/186963/2 "2019-06-24T02:05:47Z")

</div>

Finally figured this one out. I replaced the line:

**math "mean(percentage)"**

with:

**if {rowCount | eq 0} then=0 else={math "mean(percentage)"}**

If the datatable is not empty, then it returns the average of the "percentage" column, otherwise it returns an "average" value of 0. Now I no longer get the error triangle at runtime of the canvas.

---

_[View the full topic](https://discuss.elastic.co/t/handling-an-empty-datatable/186963)._
