# How to return default value for getCell

**URL:** <https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565>\
**Category:** Kibana\
**Created:** [April 28, 2021, 11:12pm UTC](https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565 "2021-04-28T23:12:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tangkalo](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tangkalo](https://discuss.elastic.co/u/tangkalo)\
**Post date:** [April 28, 2021, 11:12pm UTC](https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565/1 "2021-04-28T23:12:51Z")

</div>

Hi, I have the following canvas expression that uses getCell against a data source but it may return null, i.e.the kql returns nothing. Is there a way I can make getCell to return a default value when that happens. Any help will be appreciated. Thanks a lot!

| getCell "burrow\_maxlag"  
| shape fill=if {gt 5000} then="#F9BB11" else="#9bc7a0"} border="#070707" borderWidth=0.5 maintainAspect=false "square"  
| render

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [April 28, 2021, 11:50pm UTC](https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565/2 "2021-04-28T23:50:28Z")

</div>

You can try _[COALESCE](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-functions-conditional.html#sql-functions-conditional-coalesce)_

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [April 28, 2021, 11:53pm UTC](https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565/3 "2021-04-28T23:53:30Z")

</div>

or [switch case](https://www.elastic.co/guide/en/kibana/master/canvas-function-reference.html#compare_fn) example

---

<div class="post-metadata">

**Author:** ![tangkalo](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tangkalo](https://discuss.elastic.co/u/tangkalo)\
**Post date:** [April 29, 2021, 2:21am UTC](https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565/4 "2021-04-29T02:21:54Z")

</div>

Thanks for the help. I tried the following but when there's no data return from essql, it still goes to then="#F9BB11"

I am new to canvas function and suspect that my nested if must be missing some parentheses or something. Any idea? Thanks.

| shape fill={if {rowCount | lt 1} then="#9bc7a0"  
else={if getCell "burrow\_maxlag" | compare "gt" to=1} then="#F9BB11"  
else="#9bc7a0"} border="#070707" borderWidth=0.5 maintainAspect=false "square"  
| render

---

<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:** [May 27, 2021, 2:22am UTC](https://discuss.elastic.co/t/how-to-return-default-value-for-getcell/271565/5 "2021-05-27T02:22:44Z")

</div>

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