# SQL expression to calculate the percentage

**URL:** https://discuss.elastic.co/t/sql-expression-to-calculate-the-percentage/271732
**Category:** Kibana
**Created:** [April 30, 2021, 2:15am UTC](https://discuss.elastic.co/t/sql-expression-to-calculate-the-percentage/271732 "2021-04-30T02:15:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)
#### Post date: [May 4, 2021, 2:36pm UTC](https://discuss.elastic.co/t/sql-expression-to-calculate-the-percentage/271732/2 "2021-05-04T14:36:36Z")

</div>

Maybe this answer I posted in another thread on using [TSVB](https://www.elastic.co/guide/en/kibana/current/tsvb.html) with the `Metric Output` and the `Filter Ratio` metric may be helpful to you

> [@Show colored heading in the Kibana Dashboard](https://discuss.elastic.co/t/show-colored-heading-in-the-kibana-dashboard/272039/3):
>
> In fact, depending on your data query you may be able to do this using the Metric output in TSVB that has what is called Color Rules where you can change the background and text color based in the metric value. In my example I want a ratio between status: OK and status: Error so after switching to the Metric output, in Panel Options I can add the color rules to use 0.5 as my threshold And in the data use the Filter Ratio metric type for status: OK And in the options format…

---

_[View the full topic](https://discuss.elastic.co/t/sql-expression-to-calculate-the-percentage/271732)._
