# Visualize line chart with top hit aggregation and sum

**URL:** https://discuss.elastic.co/t/visualize-line-chart-with-top-hit-aggregation-and-sum/101523
**Category:** Kibana
**Created:** [September 22, 2017, 5:54pm UTC](https://discuss.elastic.co/t/visualize-line-chart-with-top-hit-aggregation-and-sum/101523 "2017-09-22T17:54:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Martin\_Lipovsky](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martin_lipovsky/32/22433_2.png) [@Martin\_Lipovsky](https://discuss.elastic.co/u/Martin_Lipovsky)
#### Post date: [September 22, 2017, 5:54pm UTC](https://discuss.elastic.co/t/visualize-line-chart-with-top-hit-aggregation-and-sum/101523/1 "2017-09-22T17:54:51Z")

</div>

Hi, i have this kind of data...

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0ca4d8f1eaaf24f40703176dc932addd53c2fd82.png)

finger is unique per hw(computer) and put doc for example every hour... There is also total\_devices available in put time

I want to make line graph with daily date histogram on x-axe and sum of total devices on y-axes, but only newest value for unique finger

Thanks for help

---

<div class="post-metadata">

### Author: ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)
#### Post date: [September 25, 2017, 3:46am UTC](https://discuss.elastic.co/t/visualize-line-chart-with-top-hit-aggregation-and-sum/101523/2 "2017-09-25T03:46:53Z")

</div>

I have been playing around with this and haven't been able to figure out a solution. I am going to reach out and see if this is possible with the TSVB visualization.

Here is the data I have been sampling for anyone else that wants to give it a look:

```auto
DELETE discuss-101523

PUT discuss-101523
{
  "settings": {},
  "mappings": {
    "doc": {
      "properties": {
        "total_devices": {
          "type": "integer"
        },
        "finger": {
          "type": "keyword"
        },
        "date": {
          "type": "date"
        }
      }
    }
  }
}

POST discuss-101523/doc
{
  "total_devices": 11,
  "finger": "x-y-z",
  "date": "2017-09-22T01:00:00"
}

POST discuss-101523/doc
{
  "total_devices": 6,
  "finger": "x-y-z",
  "date": "2017-09-22T02:00:00"
}

POST discuss-101523/doc
{
  "total_devices": 10,
  "finger": "q-w-e",
  "date": "2017-09-22T01:00:00"
}

POST discuss-101523/doc
{
  "total_devices": 5,
  "finger": "q-w-e",
  "date": "2017-09-22T02:00:00"
}

POST /discuss-101523/_search
{
  "aggs": {
    "group": {
      "terms": {
        "field": "finger"
      },
      "aggs": {
        "group_docs": {
          "top_hits": {
            "size": 1,
            "sort": [
              {
                "date": {
                  "order": "desc"
                }
              }
            ]
          }
        }
      }
    }
  }
}

```

---

<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: [October 23, 2017, 3:51am UTC](https://discuss.elastic.co/t/visualize-line-chart-with-top-hit-aggregation-and-sum/101523/3 "2017-10-23T03:51:01Z")

</div>

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