# Count() with KQL doesn't return desired results

**URL:** <https://discuss.elastic.co/t/count-with-kql-doesnt-return-desired-results/288121>\
**Category:** Kibana\
**Tags:** lens\
**Created:** [November 1, 2021, 8:48am UTC](https://discuss.elastic.co/t/count-with-kql-doesnt-return-desired-results/288121 "2021-11-01T08:48:57Z")\
**Posts on this page:** 3\
**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:** [November 1, 2021, 8:48am UTC](https://discuss.elastic.co/t/count-with-kql-doesnt-return-desired-results/288121/1 "2021-11-01T08:48:57Z")

</div>

Hi There,

I'm using 7.15.

My elastic data are records of tests. Each test has status failed or pass.  
I want to visualize a table like this:  
**Testcase Name** | **# of failed tests** | **%of failure from all runs**

I tried to use count() function for both columns:  
For number of failed column I used: count(kql='testcaseStatus.keyword:Failed') which give me 0 counts (I tried to sort it descending to see top values first, but still 0).

For the second column, I want to know the percent of failures tests from all runs. I did use count again: count(kql='testcaseStatus.keyword:Failed') / count(), and here I also get 0.

What am I doing wrong?

See settings:

 ![numberOfFailures](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cd3102a9f1d4ddc2b54db34ca4b877ab0c5f53a2.png)

=================================================================

 ![PercentOfFailures](https://us1.discourse-cdn.com/elastic/original/3X/0/b/0b1fd76a07ae304439b1b1b3ead426e995f55a62.png)

---

<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:30am UTC](https://discuss.elastic.co/t/count-with-kql-doesnt-return-desired-results/288121/2 "2021-11-01T09:30:16Z")

</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 can be 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-with-kql-doesnt-return-desired-results/288121/3 "2021-11-29T09:30:29Z")

</div>

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