# Hey I created canvas widget using below script but widgets failed to load in 8.4.2 Version

**URL:** https://discuss.elastic.co/t/hey-i-created-canvas-widget-using-below-script-but-widgets-failed-to-load-in-8-4-2-version/317782
**Category:** Kibana
**Tags:** canvas
**Created:** [October 31, 2022, 7:12am UTC](https://discuss.elastic.co/t/hey-i-created-canvas-widget-using-below-script-but-widgets-failed-to-load-in-8-4-2-version/317782 "2022-10-31T07:12:22Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![JLeysens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jleysens/32/67404_2.png) [@JLeysens](https://discuss.elastic.co/u/JLeysens)
#### Post date: [October 31, 2022, 11:53am UTC](https://discuss.elastic.co/t/hey-i-created-canvas-widget-using-below-script-but-widgets-failed-to-load-in-8-4-2-version/317782/5 "2022-10-31T11:53:12Z")

</div>

As time passes your datatable sometimes has data other times not (since you are looking at the last 5 minutes based on your query this is probably a smallish sample set).

See this solution for handling a potentially empty datatable:

> [@Handling an empty datatable](https://discuss.elastic.co/t/handling-an-empty-datatable/186963/2):
>
> 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.

You should be able to prevent the empty datatable from causing issues for your `getCell` call too (note: `getCell` defaults to using row `0` if now value is provided, [see the docs](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html#getCell_fn))

---

_[View the full topic](https://discuss.elastic.co/t/hey-i-created-canvas-widget-using-below-script-but-widgets-failed-to-load-in-8-4-2-version/317782)._
