# Calculating purcentage in a metric

**URL:** <https://discuss.elastic.co/t/calculating-purcentage-in-a-metric/211652>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [December 12, 2019, 1:13pm UTC](https://discuss.elastic.co/t/calculating-purcentage-in-a-metric/211652 "2019-12-12T13:13:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![corey.robertson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corey.robertson/32/54611_2.png) [@corey.robertson](https://discuss.elastic.co/u/corey.robertson)\
**Post date:** [December 12, 2019, 4:45pm UTC](https://discuss.elastic.co/t/calculating-purcentage-in-a-metric/211652/2 "2019-12-12T16:45:55Z")

</div>

Hi @AchrafNGZ

I think you have an issue in your expression with some unescaped strings. You have quotes around the index name `"soc-asset-sep-"` but that is in the larger `query="" ` so those unescaped quotes are breaking the expression. You can escape them with a backslash like `FROM "soc-asset-sep-"

Here is a similar expression using one of our sample data sets to display a percent metric of orders that contain exactly 2 unique products.

```auto
filters
| essql
query="SELECT count(total_quantity) as cnt FROM \"kibana_sample_data_ecommerce\"
where total_unique_products = 2"
| math {string "cnt/" {filters | essql query="SELECT count(*) as cnt FROM \"kibana_sample_data_ecommerce\"" | math "cnt" }}
| formatnumber "0%"
| metric label="Percent of orders with 2 unique products"
| render

```

Hope that helps

---

_[View the full topic](https://discuss.elastic.co/t/calculating-purcentage-in-a-metric/211652)._
