# How to include if you don't have a row = 1 on the Learn expression canvas

**URL:** <https://discuss.elastic.co/t/how-to-include-if-you-dont-have-a-row-1-on-the-learn-expression-canvas/271981>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [May 3, 2021, 12:44pm UTC](https://discuss.elastic.co/t/how-to-include-if-you-dont-have-a-row-1-on-the-learn-expression-canvas/271981 "2021-05-03T12:44:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![francieliton\_araujo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francieliton_araujo/32/47771_2.png) [@francieliton\_araujo](https://discuss.elastic.co/u/francieliton_araujo)\
**Post date:** [May 3, 2021, 12:44pm UTC](https://discuss.elastic.co/t/how-to-include-if-you-dont-have-a-row-1-on-the-learn-expression-canvas/271981/1 "2021-05-03T12:44:59Z")

</div>

I have an SQL query to return some values, like: Avarege, warning, disaster, high. sometimes he returns all but sometimes he returns two of them, however I need to make a manipulation going through them all. I need a condition if it doesn't exist or doesn't create a defalt. Follows both the error and the expression  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/c/ecdd66c481b87cf58480d5987eef7a0a83d852b6.png)

```auto
| staticColumn name="sum" value={ply expression={math "round(mean(total) - sum(seg))"} | getCell "value"}
| mapColumn name="segundo" 
  expression={if {getCell "severidade" | eq "Normalized"} then={math "sum"} else={math "seg"}}
| mapColumn name="segundopor" expression={math "round(segundo/total*100,3)"}
| staticColumn name="average" value={getCell column="segundopor" row=0}
| staticColumn name="disaster" value={getCell column="segundopor" row=1}
| staticColumn name="high" value={getCell column="segundopor" row=2 } 
| staticColumn name="normalized" value={getCell column="segundopor" row=3}
| staticColumn name="warning" value={getCell column="segundopor" row=4}
| filterrows {getCell "severidade" | eq "Normalized"}

```

---

<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:** [May 4, 2021, 4:19am UTC](https://discuss.elastic.co/t/how-to-include-if-you-dont-have-a-row-1-on-the-learn-expression-canvas/271981/2 "2021-05-04T04:19:09Z")

</div>

You can have a look into this example

> **[APM Services overview canvas dashboard at elastic content share](https://elastic-content-share.eu/downloads/apm-services-overview-canvas/)**
>
> The APM services canvas is an adaptive canvas board that fits to your APM data. If you running Elastic APM -- try it for free!

You need to check the `rowcount` before trying to do getcell

---

<div class="post-metadata">

**Author:** ![francieliton\_araujo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francieliton_araujo/32/47771_2.png) [@francieliton\_araujo](https://discuss.elastic.co/u/francieliton_araujo)\
**Post date:** [May 4, 2021, 10:50am UTC](https://discuss.elastic.co/t/how-to-include-if-you-dont-have-a-row-1-on-the-learn-expression-canvas/271981/3 "2021-05-04T10:50:29Z")

</div>

Thanks. I managed by checking the rowcount as follows

```auto
| staticColumn name="disaster" value={if {rowCount | gte 2} then={getCell column="segundopor" row=1} else=0}

```

---

<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:** [June 1, 2021, 10:50am UTC](https://discuss.elastic.co/t/how-to-include-if-you-dont-have-a-row-1-on-the-learn-expression-canvas/271981/4 "2021-06-01T10:50:50Z")

</div>

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