# Create a count of the total of desired metric

**URL:** <https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594>\
**Category:** Kibana\
**Created:** [November 8, 2021, 7:22am UTC](https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594 "2021-11-08T07:22:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sugand](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Sugand](https://discuss.elastic.co/u/Sugand)\
**Post date:** [November 8, 2021, 7:22am UTC](https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594/1 "2021-11-08T07:22:31Z")

</div>

Hi,

I have certain visualizations in dashboard based off condition's.  
Example:  
1\> A metric of company numbers starting with number 1 and  
2\> A metric of emails staring with alphabet "a".

I want to create another visualization/metric "Sum of 1 and 2" where I would need to add/sum the count of metric of company numbers starting with number 1 AND metric of emails staring with alphabet "a".

Appreciate your input's on the same

 ![example](https://us1.discourse-cdn.com/elastic/original/3X/a/3/a39c6629c8056e38821f0605c800527461225a62.jpeg)

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [November 8, 2021, 11:05am UTC](https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594/2 "2021-11-08T11:05:00Z")

</div>

Hi @Sugand

assuming two fields `company.name` and `email` I think you could use Lens Formula to use filtered metrics on the `count` function like the following:

```auto
count(kql='company.name:1*') + count(kql='email:a*')

```

Would that work for you?

---

<div class="post-metadata">

**Author:** ![Sugand](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Sugand](https://discuss.elastic.co/u/Sugand)\
**Post date:** [November 9, 2021, 10:48am UTC](https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594/3 "2021-11-09T10:48:57Z")

</div>

@Marco_Liberati , would there be a solution to implement the same without Kibana Lens??

Appreciate your input's.

Thanks,  
Sugand

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [November 9, 2021, 11:38am UTC](https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594/4 "2021-11-09T11:38:15Z")

</div>

You can also use a TSVB metric, using a `Count` metric and a Panel filter as `company.name:1* OR email:a*`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 7, 2021, 11:38am UTC](https://discuss.elastic.co/t/create-a-count-of-the-total-of-desired-metric/288594/5 "2021-12-07T11:38:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
