# Count of Records vs Count using formula

**URL:** <https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914>\
**Category:** Kibana\
**Tags:** lens\
**Created:** [October 17, 2021, 7:48am UTC](https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914 "2021-10-17T07:48:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [October 17, 2021, 7:48am UTC](https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914/1 "2021-10-17T07:48:18Z")

</div>

Hi,

I'm using version 7.15

I have data that each record is a test results.

I'm trying to build this table, that contain failed tests only:  
Test Name Fail Tests Count Success Rate (%)  
Test 1 4 80%  
Test 2 3 90%

First I did this, I used a filter to bring only the failed tests, but than I can't get the pass rate:

 ![CountFailed](https://us1.discourse-cdn.com/elastic/original/3X/c/a/ca5b64886141c3aaaa4ae4cd184954d793bbfa25.png)

Now I want to add the "Success Rate" so I'm removing the filter that bring only the failed tests because I want to know the pass rate from all tests that run.

So I tried to replace the value of the column "Fail Tests Count" using a formula:  
count(kql='testcaseStatus.keyword:Failed')

But I don't get the same results of Count of Records:

 ![CountFailed_formula](https://us1.discourse-cdn.com/elastic/original/3X/4/1/41e7eec03b60ed17b0c5bbab5040b1bb8326b56d.png)

Why there are differences? Shouldn't it give the same result?

Thanks,  
Shay

---

<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:** [October 18, 2021, 9:36am UTC](https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914/2 "2021-10-18T09:36:32Z")

</div>

Hi @ShayWeizman

can you confirm that when using the `Count` function you've defined also a `Filter by` option with the `testcaseStatus.keyword:Failed` KQL query?

I've tried to replicate the issue on this example but it works on my 7.15 instance:

 ![Screenshot 2021-10-18 at 11.34.53](https://us1.discourse-cdn.com/elastic/original/3X/9/3/93ac2620436bc8cadebc19a60ab3fb50875b35cf.png)

From here clicking the `Formula` tab should translate the `Quick function` configuration into this formula:

![Screenshot 2021-10-18 at 11.36.11](https://us1.discourse-cdn.com/elastic/original/3X/2/7/271cbceed78579b01b0d63ddf88ea8e7a94af0fb.png)

Which shows the same chart.

---

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [November 1, 2021, 9:02am UTC](https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914/3 "2021-11-01T09:02:22Z")

</div>

I've removed the filter from the global filters so I will get all results and tried to use count to get the failed tests.

---

<div class="post-metadata">

**Author:** ![ShayWeizman](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@ShayWeizman](https://discuss.elastic.co/u/ShayWeizman)\
**Post date:** [November 1, 2021, 9:29am UTC](https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914/4 "2021-11-01T09:29:47Z")

</div>

I've removed the global filter (testcaseStatus.keyword: Failed) and set it as the one of the columns filter and it works as I expected. So this issue is closed

---

<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:** [November 29, 2021, 9:30am UTC](https://discuss.elastic.co/t/count-of-records-vs-count-using-formula/286914/5 "2021-11-29T09:30:29Z")

</div>

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