# Conditionals in Canvas

**URL:** <https://discuss.elastic.co/t/conditionals-in-canvas/168796>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [February 18, 2019, 9:47am UTC](https://discuss.elastic.co/t/conditionals-in-canvas/168796 "2019-02-18T09:47:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rozling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rozling/32/16401_2.png) [@rozling](https://discuss.elastic.co/u/rozling)\
**Post date:** [February 18, 2019, 10:29am UTC](https://discuss.elastic.co/t/conditionals-in-canvas/168796/2 "2019-02-18T10:29:57Z")

</div>

Got it working as a switch! Here's the full query rendering to a markdown element:

```
filters
| essql 
  query="SELECT \"@timestamp\", \"monitor.status\" as status FROM \"heartbeat*\" WHERE QUERY('my_service') LIMIT 1"
| mapColumn value
  fn=${getCell status | switch 
    {case if={compare eq to="up"} then=Healthy}
    {case if={compare eq to="down"} then=Unhealthy}
    default="Unknown"
  }
| markdown "{{#each rows}}
# {{value}}
{{/each}}" 
  font={font family="'Open Sans', Helvetica, Arial, sans-serif" size=18 align="left" color="#000000" weight="bold" underline=false italic=false}
| render containerStyle={containerStyle}

```

(not sure the `{{#each rows}}` etc is necessary, happy to take advice on that.

Also FYI I got the answer from this blog post: [Canvas Blog Stream](https://discuss.elastic.co/t/canvas-blog-stream/126823/29?u=rozling)

And found examples here: [https://github.com/alexfrancoeur/kibana\_canvas\_examples](https://github.com/alexfrancoeur/kibana_canvas_examples)

---

_[View the full topic](https://discuss.elastic.co/t/conditionals-in-canvas/168796)._
