# Conditional colouring using kibana canvas expression editor

**URL:** https://discuss.elastic.co/t/conditional-colouring-using-kibana-canvas-expression-editor/177929
**Category:** Kibana
**Tags:** canvas
**Created:** [April 23, 2019, 3:42am UTC](https://discuss.elastic.co/t/conditional-colouring-using-kibana-canvas-expression-editor/177929 "2019-04-23T03:42:57Z")
**Posts on this page:** 1
**Showing post:** 18

<div class="post-metadata">

### Author: ![Catherine\_Liu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catherine_liu/32/34294_2.png) [@Catherine\_Liu](https://discuss.elastic.co/u/Catherine_Liu)
#### Post date: [June 28, 2019, 9:11pm UTC](https://discuss.elastic.co/t/conditional-colouring-using-kibana-canvas-expression-editor/177929/18 "2019-06-28T21:11:30Z")

</div>

@ScottBarnes @sharonva You can't conditionally change the color of the background, because sub-expressions in the `render` function receive a `render` object as context and tries to compare your conditional expressions to the `render` object.

The simple way around this is to add a separate `shape` element that serves as a background element hooked up to the same datasource where you have access to your datasource to conditionally render the color of the `shape`.

Another solution would be to pipe the same datasource into the beginning of your conditional sub-expression.

For example:

```auto
...
| render containerStyle={
     containerStyle backgroundColor={
       filters | demodata | math "sum(price)" | if {gt 50} then="red" else="green"
     } 
  }
```

---

_[View the full topic](https://discuss.elastic.co/t/conditional-colouring-using-kibana-canvas-expression-editor/177929)._
