# Date Aggregation Help

**URL:** https://discuss.elastic.co/t/date-aggregation-help/19551
**Category:** Elasticsearch
**Created:** [September 1, 2014, 11:55am UTC](https://discuss.elastic.co/t/date-aggregation-help/19551 "2014-09-01T11:55:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Simon\_Edwards](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Simon\_Edwards](https://discuss.elastic.co/u/Simon_Edwards)
#### Post date: [September 1, 2014, 11:55am UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/1 "2014-09-01T11:55:51Z")

</div>

Hi,

I was wondering if somebody familiar with aggregations, particularly date  
histogram aggregations, can point me in the right direction.

I'm currently looking to get a total count of records over a specific time  
period. Each record contains a "date\_submitted" field and if they're  
closed, contain a "date\_closed" field.

Is it possible to aggregate the records based off these values (i.e. only  
showing open issues for a weekly period, even if the record was submitted a  
year ago)? If so where abouts are the aggregations specified? In the  
dashboard JSON or within the index mapping?

Many thanks in advance.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)
#### Post date: [September 1, 2014, 1:10pm UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/2 "2014-09-01T13:10:55Z")

</div>

Hello Simon ,

I believe this can be done in this manner.  
Do 2 separate date histogram on the date\_submitted field and date\_closed  
field.  
The sum of count of date\_submitted minus the sum of count on date\_closed  
on all the previous date should give you the number of open issues for that  
week.

For eg:

Week1 - Open - 10 , closed - 5  
Week2 - Open 20 m ,closed 6  
Week3 - Open 30 , closed 10

Number of open issues on  
Week1 - 10  
Week2 - (20 + 10 ) - 5 = 25  
Week3 - ( 30 + 20 + 10 ) - (6 + 5) = 49

Thanks  
Vineeth

On Mon, Sep 1, 2014 at 5:25 PM, Simon Edwards [simon\_edwards@scee.net](mailto:simon_edwards@scee.net)  
wrote:

> Hi,
> 
> I was wondering if somebody familiar with aggregations, particularly date  
> histogram aggregations, can point me in the right direction.
> 
> I'm currently looking to get a total count of records over a specific time  
> period. Each record contains a "date\_submitted" field and if they're  
> closed, contain a "date\_closed" field.
> 
> Is it possible to aggregate the records based off these values (i.e. only  
> showing open issues for a weekly period, even if the record was submitted a  
> year ago)? If so where abouts are the aggregations specified? In the  
> dashboard JSON or within the index mapping?
> 
> Many thanks in advance.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5m3oacS75hV6nSeXR0ZasC7RyL2SqDh1vk%2B1VXUKFNd\_w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5m3oacS75hV6nSeXR0ZasC7RyL2SqDh1vk%2B1VXUKFNd_w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Simon\_Edwards](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Simon\_Edwards](https://discuss.elastic.co/u/Simon_Edwards)
#### Post date: [September 1, 2014, 2:29pm UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/3 "2014-09-01T14:29:46Z")

</div>

Hello Vineeth,

Many thanks for your reply, sounds like your method should work a treat!

One quick noob question, where abouts are the date histograms aggregations  
created? Are they created on the index or on the dashboard itself? Any help  
is appreciated.

Cheers,  
Si.

On Monday, September 1, 2014 2:11:02 PM UTC+1, vineeth mohan wrote:

> Hello Simon ,
> 
> I believe this can be done in this manner.  
> Do 2 separate date histogram on the date\_submitted field and date\_closed  
> field.  
> The sum of count of date\_submitted minus the sum of count on date\_closed  
> on all the previous date should give you the number of open issues for that  
> week.
> 
> For eg:
> 
> Week1 - Open - 10 , closed - 5  
> Week2 - Open 20 m ,closed 6  
> Week3 - Open 30 , closed 10
> 
> Number of open issues on  
> Week1 - 10  
> Week2 - (20 + 10 ) - 5 = 25  
> Week3 - ( 30 + 20 + 10 ) - (6 + 5) = 49
> 
> Thanks  
> Vineeth
> 
> On Mon, Sep 1, 2014 at 5:25 PM, Simon Edwards \<[simon\_...@scee.net](mailto:simon_...@scee.net)  
> \<javascript:\>\> wrote:
> 
> > Hi,
> > 
> > I was wondering if somebody familiar with aggregations, particularly date  
> > histogram aggregations, can point me in the right direction.
> > 
> > I'm currently looking to get a total count of records over a specific  
> > time period. Each record contains a "date\_submitted" field and if they're  
> > closed, contain a "date\_closed" field.
> > 
> > Is it possible to aggregate the records based off these values (i.e. only  
> > showing open issues for a weekly period, even if the record was submitted a  
> > year ago)? If so where abouts are the aggregations specified? In the  
> > dashboard JSON or within the index mapping?
> > 
> > Many thanks in advance.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)
#### Post date: [September 1, 2014, 3:11pm UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/4 "2014-09-01T15:11:55Z")

</div>

Hello Simon ,

I didn't quite understand your question.  
Kindly elaborate.

Thanks  
Vineeth

On Mon, Sep 1, 2014 at 7:59 PM, Simon Edwards [simon\_edwards@scee.net](mailto:simon_edwards@scee.net)  
wrote:

> Hello Vineeth,
> 
> Many thanks for your reply, sounds like your method should work a treat!
> 
> One quick noob question, where abouts are the date histograms aggregations  
> created? Are they created on the index or on the dashboard itself? Any help  
> is appreciated.
> 
> Cheers,  
> Si.
> 
> On Monday, September 1, 2014 2:11:02 PM UTC+1, vineeth mohan wrote:
> 
> > Hello Simon ,
> > 
> > I believe this can be done in this manner.  
> > Do 2 separate date histogram on the date\_submitted field and date\_closed  
> > field.  
> > The sum of count of date\_submitted minus the sum of count on date\_closed  
> > on all the previous date should give you the number of open issues for that  
> > week.
> > 
> > For eg:
> > 
> > Week1 - Open - 10 , closed - 5  
> > Week2 - Open 20 m ,closed 6  
> > Week3 - Open 30 , closed 10
> > 
> > Number of open issues on  
> > Week1 - 10  
> > Week2 - (20 + 10 ) - 5 = 25  
> > Week3 - ( 30 + 20 + 10 ) - (6 + 5) = 49
> > 
> > Thanks  
> > Vineeth
> > 
> > On Mon, Sep 1, 2014 at 5:25 PM, Simon Edwards [simon\_...@scee.net](mailto:simon_...@scee.net) wrote:
> > 
> > > Hi,
> > > 
> > > I was wondering if somebody familiar with aggregations, particularly  
> > > date histogram aggregations, can point me in the right direction.
> > > 
> > > I'm currently looking to get a total count of records over a specific  
> > > time period. Each record contains a "date\_submitted" field and if they're  
> > > closed, contain a "date\_closed" field.
> > > 
> > > Is it possible to aggregate the records based off these values (i.e.  
> > > only showing open issues for a weekly period, even if the record was  
> > > submitted a year ago)? If so where abouts are the aggregations specified?  
> > > In the dashboard JSON or within the index mapping?
> > > 
> > > Many thanks in advance.
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5no\_tFxcNbh9huv1Bos2hjE-B-mWq5%3DL83vKg-ygROT3Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5no_tFxcNbh9huv1Bos2hjE-B-mWq5%3DL83vKg-ygROT3Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Simon\_Edwards](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Simon\_Edwards](https://discuss.elastic.co/u/Simon_Edwards)
#### Post date: [September 1, 2014, 3:29pm UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/5 "2014-09-01T15:29:35Z")

</div>

Hello Vineeth,

My question was regarding where to set up the date histograms. Do i simply  
add a section to the dashboard JSON or do I need to update the  
index field mappings? If you could provide a small example that'd be great.

Thanks for all your help!

On Monday, September 1, 2014 4:12:14 PM UTC+1, vineeth mohan wrote:

> Hello Simon ,
> 
> I didn't quite understand your question.  
> Kindly elaborate.
> 
> Thanks  
> Vineeth
> 
> On Mon, Sep 1, 2014 at 7:59 PM, Simon Edwards \<[simon\_...@scee.net](mailto:simon_...@scee.net)  
> \<javascript:\>\> wrote:
> 
> > Hello Vineeth,
> > 
> > Many thanks for your reply, sounds like your method should work a treat!
> > 
> > One quick noob question, where abouts are the date histograms  
> > aggregations created? Are they created on the index or on the dashboard  
> > itself? Any help is appreciated.
> > 
> > Cheers,  
> > Si.
> > 
> > On Monday, September 1, 2014 2:11:02 PM UTC+1, vineeth mohan wrote:
> > 
> > > Hello Simon ,
> > > 
> > > I believe this can be done in this manner.  
> > > Do 2 separate date histogram on the date\_submitted field and date\_closed  
> > > field.  
> > > The sum of count of date\_submitted minus the sum of count on  
> > > date\_closed on all the previous date should give you the number of open  
> > > issues for that week.
> > > 
> > > For eg:
> > > 
> > > Week1 - Open - 10 , closed - 5  
> > > Week2 - Open 20 m ,closed 6  
> > > Week3 - Open 30 , closed 10
> > > 
> > > Number of open issues on  
> > > Week1 - 10  
> > > Week2 - (20 + 10 ) - 5 = 25  
> > > Week3 - ( 30 + 20 + 10 ) - (6 + 5) = 49
> > > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Mon, Sep 1, 2014 at 5:25 PM, Simon Edwards [simon\_...@scee.net](mailto:simon_...@scee.net)  
> > > wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I was wondering if somebody familiar with aggregations, particularly  
> > > > date histogram aggregations, can point me in the right direction.
> > > > 
> > > > I'm currently looking to get a total count of records over a specific  
> > > > time period. Each record contains a "date\_submitted" field and if they're  
> > > > closed, contain a "date\_closed" field.
> > > > 
> > > > Is it possible to aggregate the records based off these values (i.e.  
> > > > only showing open issues for a weekly period, even if the record was  
> > > > submitted a year ago)? If so where abouts are the aggregations specified?  
> > > > In the dashboard JSON or within the index mapping?
> > > > 
> > > > Many thanks in advance.
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > 
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)
#### Post date: [September 1, 2014, 4:03pm UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/6 "2014-09-01T16:03:31Z")

</div>

Hello Simon ,

I hope you are familiar with Elasticsearch API.  
I believe by dashboard you are meaning Kibana.  
If that is the case , you wont be able to see this result there as Kibana  
does not currently offers this level of flexibility.

You will need to write JSON agg query based on -

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

There need not be any work on schma or index to use this.  
Hope that helps.

Thanks  
Vineeth

On Mon, Sep 1, 2014 at 8:59 PM, Simon Edwards [simon\_edwards@scee.net](mailto:simon_edwards@scee.net)  
wrote:

> Hello Vineeth,
> 
> My question was regarding where to set up the date histograms. Do i simply  
> add a section to the dashboard JSON or do I need to update the  
> index field mappings? If you could provide a small example that'd be great.
> 
> Thanks for all your help!
> 
> On Monday, September 1, 2014 4:12:14 PM UTC+1, vineeth mohan wrote:
> 
> > Hello Simon ,
> > 
> > I didn't quite understand your question.  
> > Kindly elaborate.
> > 
> > Thanks  
> > Vineeth
> > 
> > On Mon, Sep 1, 2014 at 7:59 PM, Simon Edwards [simon\_...@scee.net](mailto:simon_...@scee.net) wrote:
> > 
> > > Hello Vineeth,
> > > 
> > > Many thanks for your reply, sounds like your method should work a treat!
> > > 
> > > One quick noob question, where abouts are the date histograms  
> > > aggregations created? Are they created on the index or on the dashboard  
> > > itself? Any help is appreciated.
> > > 
> > > Cheers,  
> > > Si.
> > > 
> > > On Monday, September 1, 2014 2:11:02 PM UTC+1, vineeth mohan wrote:
> > > 
> > > > Hello Simon ,
> > > > 
> > > > I believe this can be done in this manner.  
> > > > Do 2 separate date histogram on the date\_submitted field and  
> > > > date\_closed field.  
> > > > The sum of count of date\_submitted minus the sum of count on  
> > > > date\_closed on all the previous date should give you the number of open  
> > > > issues for that week.
> > > > 
> > > > For eg:
> > > > 
> > > > Week1 - Open - 10 , closed - 5  
> > > > Week2 - Open 20 m ,closed 6  
> > > > Week3 - Open 30 , closed 10
> > > > 
> > > > Number of open issues on  
> > > > Week1 - 10  
> > > > Week2 - (20 + 10 ) - 5 = 25  
> > > > Week3 - ( 30 + 20 + 10 ) - (6 + 5) = 49
> > > > 
> > > > Thanks  
> > > > Vineeth
> > > > 
> > > > On Mon, Sep 1, 2014 at 5:25 PM, Simon Edwards [simon\_...@scee.net](mailto:simon_...@scee.net)  
> > > > wrote:
> > > > 
> > > > > Hi,
> > > > > 
> > > > > I was wondering if somebody familiar with aggregations, particularly  
> > > > > date histogram aggregations, can point me in the right direction.
> > > > > 
> > > > > I'm currently looking to get a total count of records over a specific  
> > > > > time period. Each record contains a "date\_submitted" field and if they're  
> > > > > closed, contain a "date\_closed" field.
> > > > > 
> > > > > Is it possible to aggregate the records based off these values (i.e.  
> > > > > only showing open issues for a weekly period, even if the record was  
> > > > > submitted a year ago)? If so where abouts are the aggregations specified?  
> > > > > In the dashboard JSON or within the index mapping?
> > > > > 
> > > > > Many thanks in advance.
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > 
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40goo  
> > > > > [glegroups.com](http://glegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5m8g7frbMpfviXu7Enh7ncJmfsCingUKuwGS%2BPEOntbLg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5m8g7frbMpfviXu7Enh7ncJmfsCingUKuwGS%2BPEOntbLg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Simon\_Edwards](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Simon\_Edwards](https://discuss.elastic.co/u/Simon_Edwards)
#### Post date: [September 1, 2014, 4:10pm UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/7 "2014-09-01T16:10:08Z")

</div>

Thanks for all your help Vineeth

On Monday, September 1, 2014 5:03:38 PM UTC+1, vineeth mohan wrote:

> Hello Simon ,
> 
> I hope you are familiar with Elasticsearch API.  
> I believe by dashboard you are meaning Kibana.  
> If that is the case , you wont be able to see this result there as Kibana  
> does not currently offers this level of flexibility.
> 
> You will need to write JSON agg query based on -  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html#search-aggregations-bucket-datehistogram-aggregation)
> 
> There need not be any work on schma or index to use this.  
> Hope that helps.
> 
> Thanks  
> Vineeth
> 
> On Mon, Sep 1, 2014 at 8:59 PM, Simon Edwards \<[simon\_...@scee.net](mailto:simon_...@scee.net)  
> \<javascript:\>\> wrote:
> 
> > Hello Vineeth,
> > 
> > My question was regarding where to set up the date histograms. Do i  
> > simply add a section to the dashboard JSON or do I need to  
> > update the index field mappings? If you could provide a small example  
> > that'd be great.
> > 
> > Thanks for all your help!
> > 
> > On Monday, September 1, 2014 4:12:14 PM UTC+1, vineeth mohan wrote:
> > 
> > > Hello Simon ,
> > > 
> > > I didn't quite understand your question.  
> > > Kindly elaborate.
> > > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Mon, Sep 1, 2014 at 7:59 PM, Simon Edwards [simon\_...@scee.net](mailto:simon_...@scee.net)  
> > > wrote:
> > > 
> > > > Hello Vineeth,
> > > > 
> > > > Many thanks for your reply, sounds like your method should work a treat!
> > > > 
> > > > One quick noob question, where abouts are the date histograms  
> > > > aggregations created? Are they created on the index or on the dashboard  
> > > > itself? Any help is appreciated.
> > > > 
> > > > Cheers,  
> > > > Si.
> > > > 
> > > > On Monday, September 1, 2014 2:11:02 PM UTC+1, vineeth mohan wrote:
> > > > 
> > > > > Hello Simon ,
> > > > > 
> > > > > I believe this can be done in this manner.  
> > > > > Do 2 separate date histogram on the date\_submitted field and  
> > > > > date\_closed field.  
> > > > > The sum of count of date\_submitted minus the sum of count on  
> > > > > date\_closed on all the previous date should give you the number of open  
> > > > > issues for that week.
> > > > > 
> > > > > For eg:
> > > > > 
> > > > > Week1 - Open - 10 , closed - 5  
> > > > > Week2 - Open 20 m ,closed 6  
> > > > > Week3 - Open 30 , closed 10
> > > > > 
> > > > > Number of open issues on  
> > > > > Week1 - 10  
> > > > > Week2 - (20 + 10 ) - 5 = 25  
> > > > > Week3 - ( 30 + 20 + 10 ) - (6 + 5) = 49
> > > > > 
> > > > > Thanks  
> > > > > Vineeth
> > > > > 
> > > > > On Mon, Sep 1, 2014 at 5:25 PM, Simon Edwards [simon\_...@scee.net](mailto:simon_...@scee.net)  
> > > > > wrote:
> > > > > 
> > > > > > Hi,
> > > > > > 
> > > > > > I was wondering if somebody familiar with aggregations, particularly  
> > > > > > date histogram aggregations, can point me in the right direction.
> > > > > > 
> > > > > > I'm currently looking to get a total count of records over a specific  
> > > > > > time period. Each record contains a "date\_submitted" field and if they're  
> > > > > > closed, contain a "date\_closed" field.
> > > > > > 
> > > > > > Is it possible to aggregate the records based off these values (i.e.  
> > > > > > only showing open issues for a weekly period, even if the record was  
> > > > > > submitted a year ago)? If so where abouts are the aggregations specified?  
> > > > > > In the dashboard JSON or within the index mapping?
> > > > > > 
> > > > > > Many thanks in advance.
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > > > 
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40goo  
> > > > > > [glegroups.com](http://glegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e448bc2-007b-4c7b-a073-fcb1a8017eed%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > > .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%  
> > > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b9df0286-fac1-41be-89a5-be062e8a9f55%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/aadc5927-f268-4016-a8b9-da3d6512e0b4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6c42d7aa-fd64-46f8-abd1-c15ef9d2cf60%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6c42d7aa-fd64-46f8-abd1-c15ef9d2cf60%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:05am UTC](https://discuss.elastic.co/t/date-aggregation-help/19551/8 "2017-07-06T01:05:07Z")

</div>


