# Zero like result in canvas

**URL:** <https://discuss.elastic.co/t/zero-like-result-in-canvas/269694>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [April 9, 2021, 10:27am UTC](https://discuss.elastic.co/t/zero-like-result-in-canvas/269694 "2021-04-09T10:27:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EduardoM](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@EduardoM](https://discuss.elastic.co/u/EduardoM)\
**Post date:** [April 9, 2021, 10:27am UTC](https://discuss.elastic.co/t/zero-like-result-in-canvas/269694/1 "2021-04-09T10:27:36Z")

</div>

I have a question, on Metric, I can have the "0" like result because I have this symbol:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/b/0b8f3639d7c90b1f57ba518bc5c0ab83a4525b36.png)

and i want to have "0" instead of this symbol.  
Could anyone help me ? I can not it solve.

```
filters
| essql 
  query="SELECT SUM(length) AS sum FROM \"data-*\"
WHERE QUERY ('ptx')
AND status = 4
AND id = 2"
| math "sum"
| metric " " 
  metricFont={font align="center" color="#00a0e3" family="'Open Sans', Helvetica, Arial, sans-serif" italic=false size=60 underline=false weight="bold"} 
  labelFont={font align="center" color="#FFFFFF" family="'Open Sans', Helvetica, Arial, sans-serif" italic=false size=30 underline=false weight="normal"} metricFormat="0,0.[0]"
| render
```

---

<div class="post-metadata">

**Author:** ![Felix\_Roessel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_roessel/32/41623_2.png) [@Felix\_Roessel](https://discuss.elastic.co/u/Felix_Roessel)\
**Post date:** [April 9, 2021, 12:04pm UTC](https://discuss.elastic.co/t/zero-like-result-in-canvas/269694/2 "2021-04-09T12:04:41Z")

</div>

I guess this happens when there are no results to your query right?  
You could add a check for the row count.  
If row count is 0 then you show the zero value.

---

<div class="post-metadata">

**Author:** ![EduardoM](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@EduardoM](https://discuss.elastic.co/u/EduardoM)\
**Post date:** [April 9, 2021, 1:35pm UTC](https://discuss.elastic.co/t/zero-like-result-in-canvas/269694/3 "2021-04-09T13:35:39Z")

</div>

Well this happened because I have changed the dates of my filter, because I do not always have data, so when this happens I would like it to show me zero and not the error, it would be a better presentation. As it is, I should do the check, because I tried to use IF but I think I did something wrong, could you tell me how the check would be?

---

<div class="post-metadata">

**Author:** ![Felix\_Roessel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_roessel/32/41623_2.png) [@Felix\_Roessel](https://discuss.elastic.co/u/Felix_Roessel)\
**Post date:** [April 10, 2021, 4:56am UTC](https://discuss.elastic.co/t/zero-like-result-in-canvas/269694/4 "2021-04-10T04:56:05Z")

</div>

Replace your math function with the following. That should work

```
var_set "sum" value={if condition={rowCount | gt 0} then={getCell column="sum"} else=0}
math {var sum}
```

---

<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 8, 2021, 4:56am UTC](https://discuss.elastic.co/t/zero-like-result-in-canvas/269694/5 "2021-05-08T04:56:24Z")

</div>

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