# If math get unknown error

**URL:** <https://discuss.elastic.co/t/if-math-get-unknown-error/373851>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [January 29, 2025, 4:45pm UTC](https://discuss.elastic.co/t/if-math-get-unknown-error/373851 "2025-01-29T16:45:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattiHatem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattihatem/32/141032_2.png) [@MattiHatem](https://discuss.elastic.co/u/MattiHatem)\
**Post date:** [January 29, 2025, 4:45pm UTC](https://discuss.elastic.co/t/if-math-get-unknown-error/373851/1 "2025-01-29T16:45:47Z")

</div>

Hi, when I try to pass the blow I got this error

**Expression failed with the message:**  
**[if] \> [math] \> Unknown variable: count**

```auto
filters
| essql 
  query="SELECT COUNT(*) as count FROM \"reservation-event*\" WHERE message.affiliateName='xyz' AND message.statusName='Con' AND environment.keyword='Prod' AND \"@timestamp\" > NOW() - INTERVAL 1 HOUR"
| math "count"
| if condition={math "count" | lt 1} 
  then={shape shape="rectangle" fill="red" border="rgba(255,255,255,0)" borderWidth=0 maintainAspect=true} 
  else={shape shape="rectangle" fill="green" border="rgba(255,255,255,0)" borderWidth=0 maintainAspect=true}

```

basically I am trying to make the shape red if it is less than 1 if more then green

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [February 4, 2025, 2:38pm UTC](https://discuss.elastic.co/t/if-math-get-unknown-error/373851/2 "2025-02-04T14:38:53Z")

</div>

Hi @MattiHatem.

The `condition` argument in the [`if` expression](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html#if_fn) will read from the current context which you've piped in with the previous `math "count"` line. Also, there is no "rectangle" shape type. You probably want "square". [This is the list of available shapes](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/expression_shape/common/types/expression_functions.ts#L16-L33).

I think this expression should work for you.

```auto
filters
| essql 
  query="SELECT COUNT(*) as count FROM \"reservation-event*\" WHERE message.affiliateName='xyz' AND message.statusName='Con' AND environment.keyword='Prod' AND \"@timestamp\" > NOW() - INTERVAL 1 HOUR"
| math "count"
| if condition={ lt 1 } 
  then={shape shape="square" fill="red" border="rgba(255,255,255,0)" borderWidth=0 maintainAspect=true} 
  else={shape shape="square" fill="green" border="rgba(255,255,255,0)" borderWidth=0 maintainAspect=true}

```
