# Counting instances per day

**URL:** <https://discuss.elastic.co/t/counting-instances-per-day/198780>\
**Category:** Kibana\
**Created:** [September 9, 2019, 8:18pm UTC](https://discuss.elastic.co/t/counting-instances-per-day/198780 "2019-09-09T20:18:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cblackburn36](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@cblackburn36](https://discuss.elastic.co/u/cblackburn36)\
**Post date:** [September 9, 2019, 8:18pm UTC](https://discuss.elastic.co/t/counting-instances-per-day/198780/1 "2019-09-09T20:18:31Z")

</div>

Hi All,

We have some documents where an id code is logged against a day. Something like:-

{  
id: 12345,  
date: 09-09-2019  
}

Where 12345 changes and there are a bunch of documents each day.

We want to count the number of times an id code is present in the last X days, 7 for example. Ideally we would have a report where, for each day present in the date filter chosen, it would give a line showing how often each asset was seen in the last X days. That might not be the clearest of explanations so I've included a table showing what we'd like:-

| | 12345 | 23456 | 34567 | 45678 |
| --- | --- | --- | --- | --- |
| 01-09-2019 | | 1 | 1 | |
| 02-09-2019 | 1 | 2 | 2 | |
| 03-09-2019 | 2 | 3 | 3 | 1 |
| 04-09-2019 | 3 | 4 | 4 | 2 |
| 05-09-2019 | | | 5 | 3 |
| 06-09-2019 | 3 | | 6 | 4 |

Basically there's two core things to achieve here.

1. Look back 7 days and see the number of times a document is present
2. Pivot the ID's up onto the columns instead of them being rows

Any ideas on how I can get Kibana to do this?

Thanks in advance

Chris

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [September 9, 2019, 8:33pm UTC](https://discuss.elastic.co/t/counting-instances-per-day/198780/2 "2019-09-09T20:33:17Z")

</div>

The closest feature to this is the Machine Learning [data frame transforms](https://www.elastic.co/guide/en/kibana/current/creating-df-kib.html) which lets you create pivots. It might be possible to create a similar query using SQL in the Canvas tool, or by using an ETL tool

---

<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 7, 2019, 8:33pm UTC](https://discuss.elastic.co/t/counting-instances-per-day/198780/3 "2019-10-07T20:33:50Z")

</div>

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