# Calculate count based on the latest document

**URL:** <https://discuss.elastic.co/t/calculate-count-based-on-the-latest-document/188028>\
**Category:** Elasticsearch\
**Created:** [June 28, 2019, 10:32am UTC](https://discuss.elastic.co/t/calculate-count-based-on-the-latest-document/188028 "2019-06-28T10:32:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![statsabdessamad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/statsabdessamad/32/49006_2.png) [@statsabdessamad](https://discuss.elastic.co/u/statsabdessamad)\
**Post date:** [June 28, 2019, 10:32am UTC](https://discuss.elastic.co/t/calculate-count-based-on-the-latest-document/188028/1 "2019-06-28T10:32:29Z")

</div>

Suppose we have log files with the following structure :

## Doc 1 : Recieved\_at Risk

"2019-06-26T20:32:57.008Z", "High", "VULN1"  
"2019-06-26T20:32:57.008Z", "High", "VULN2"  
"2019-06-26T20:32:57.008Z", "Meduim", "VULN3"  
"2019-06-26T20:32:57.008Z", "Low", "VULN4"  
"2019-06-26T20:32:57.008Z", "Low", "VULN5"

## Doc 2 : (the latest version of the same doc) Recieved\_at Risk

"2019-16-26T20:32:57.008Z", "High", "VULN1"  
"2019-16-26T20:32:57.008Z", "Meduim", "VULN3"  
"2019-16-26T20:32:57.008Z", "Low", "VULN4"  
"2019-16-26T20:32:57.008Z", "Low", "VULN5"

The two documents are periodically generated from a vulnerability scanner, and they are related to the same target .

I've managed to parse and import those reports to ELK using logstash filters, And now I'm looking for a way to create a visualization (risk dashboard) based on the latest generated report.

I tried to use the count metric, but I don't have control over the date/time parameter.

Is there any possibility to do that ?

---

<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:** [July 26, 2019, 10:32am UTC](https://discuss.elastic.co/t/calculate-count-based-on-the-latest-document/188028/2 "2019-07-26T10:32:31Z")

</div>

Closed on July 26, 2019, 10:32am UTC

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