# Canvas Multiple Math Functions ESSQL

**URL:** <https://discuss.elastic.co/t/canvas-multiple-math-functions-essql/249302>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [September 21, 2020, 4:54am UTC](https://discuss.elastic.co/t/canvas-multiple-math-functions-essql/249302 "2020-09-21T04:54:20Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![karnamonkster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karnamonkster/32/67266_2.png) [@karnamonkster](https://discuss.elastic.co/u/karnamonkster)\
**Post date:** [September 22, 2020, 5:42am UTC](https://discuss.elastic.co/t/canvas-multiple-math-functions-essql/249302/3 "2020-09-22T05:42:40Z")

</div>

Hi @wylie

Thanks for your reply,  
Well we are running v7.5.2 Cluster for ES & Kibana and would not be upgrading the same till end of this year.  
On the SQL queries here they are.

**Defective Devices**  
`"SELECT COUNT(DISTINCT b4) as scount FROM \"myindex\" WHERE QUERY(' b4:/AT[0-9]+/ AND value:1')"`

**Total Devices**  
`SELECT COUNT(DISTINCT b4) as pcount FROM \"myindex\" WHERE QUERY('b4:/AT[0-9]+/')"`

An update on the last Post - While working on the issue ( **SCENARIO 1** ), i did play around the math & string function to get a number (not in percentage %).

For example: Defective Device % = 3.6%  
Number i get for OK Devices = 96.4

```
filters "live"
| essql 
  query="SELECT COUNT(DISTINCT b4) as scount FROM \"myindex\" WHERE QUERY(' b4:/AT[0-9]+/ AND value:1')"
| math 
  {string "100 - scount/" {filters | essql query="SELECT COUNT(DISTINCT b4) as pcount FROM \"myindex\" WHERE QUERY('b4:/AT[0-9]+/')" | math "pcount/100"}}
| formatnumber "0%" format="0,0.[0]%"
| metric " OK Devices" 
  metricFont={font family="'Tw Cen MT', Helvetica, Arial, sans-serif" size=72 align="center" color="#4fbf48" weight="bold" underline=false italic=false} 
  labelFont={font family="'Dubai Light', Helvetica, Arial, sans-serif" size=30 align="center" color="#FFFFFF" weight="normal" underline=false italic=false} metricFormat="0.0a"
| render
```

---

_[View the full topic](https://discuss.elastic.co/t/canvas-multiple-math-functions-essql/249302)._
