# Draw Graphs on Aggregated View of Existing Index

**URL:** <https://discuss.elastic.co/t/draw-graphs-on-aggregated-view-of-existing-index/133094>\
**Category:** Kibana\
**Created:** [May 24, 2018, 8:55am UTC](https://discuss.elastic.co/t/draw-graphs-on-aggregated-view-of-existing-index/133094 "2018-05-24T08:55:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pubudu](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@pubudu](https://discuss.elastic.co/u/pubudu)\
**Post date:** [May 24, 2018, 8:55am UTC](https://discuss.elastic.co/t/draw-graphs-on-aggregated-view-of-existing-index/133094/1 "2018-05-24T08:55:43Z")

</div>

Hi,

I have to create a dashboard in a domain where there are orders and parcels. Right now there is an existing index named "parcels". To simplify my question, lets say that this index contains the "parcel\_id", "order id" and a flag "is\_big\_parcel" and "order\_date".

I have to create two visualizations

1. show against time, the **order count** which contains "big\_parcels".
2. In a given time range, the **order count** which had 1 parcel, 2 parcels, 3 parcels.. etc

It seems to me that this can be achieved if I had an index "orders" with order\_id, order\_date, parcel\_count, and order\_has\_big\_parcel. But this is an aggregation on the already existing "parcels" index. Is it possible to create such a view based on existing "parcels" index? If not what would be the best way to achieve these visualizations?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [May 24, 2018, 2:30pm UTC](https://discuss.elastic.co/t/draw-graphs-on-aggregated-view-of-existing-index/133094/2 "2018-05-24T14:30:33Z")

</div>

hi @pubudu,

for (1) you can probably just do a filter on the `is_big_parcel` field and do a "Unique Count" (aka cardinality) metric for a Date Histogram aggregation. You would do that unique count on the `order_id` field. There is some trade-offs involved in doing cardinality ranking in Elasticsearch wrt. precision, so check with the docs if that would work for you. ([https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html)).

for (2) , I'm a little stumped on that. I don't see right away how you could do that with your current index structure. you basically want to count the number of parcels by order-id first, and then count the number of order-ids by that count. That's a two-step aggregation, and we do not expose this into Kibana as-is right now.

---

<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:** [June 21, 2018, 2:30pm UTC](https://discuss.elastic.co/t/draw-graphs-on-aggregated-view-of-existing-index/133094/3 "2018-06-21T14:30:41Z")

</div>

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