# 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:** 7

<div class="post-metadata">

### Author: ![MarkusP](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@MarkusP](https://discuss.elastic.co/u/MarkusP)
#### Post date: [May 10, 2019, 9:19am UTC](https://discuss.elastic.co/t/conditional-colouring-using-kibana-canvas-expression-editor/177929/7 "2019-05-10T09:19:20Z")

</div>

@Catherine_Liu I have basically the same problem not with the font color but with the background color

I have just one condition instead of two my approach is quite like the fist you gave to ksunil.

I do a select count(\*) and if it is greater than 0 the backround should be green otherwise it should be red.

The expression editor looks like below

`filters | essql query="SELECT * FROM uacuser WHERE logintime > NOW() - INTERVAL 1 MONTH AND disabled = 0" | math "size(userid)" | metric "Users logged in this month" metricFont={font family="'Open Sans', Helvetica, Arial, sans-serif" size=48 align="center" color="#FFFFFF" weight="normal" underline=false italic=false} labelFont={font family="'Open Sans', Helvetica, Arial, sans-serif" size=14 align="center" color="#FFFFFF" weight="normal" underline=false italic=false} | render **containerStyle={containerStyle backgroundColor={if {gt 0} then="red" else="green"}}** ` // this  
is the line that matters

It seems that the condition works not like intended , it is always else and showing a green background. Did I do something wrong? Is the condition always related to the value in the metric? Or is it possibly a bug?  
P.S How can you do that code snipet in a post?

---

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