# How to filter certain range of hours for each day in bar chart?

**URL:** <https://discuss.elastic.co/t/how-to-filter-certain-range-of-hours-for-each-day-in-bar-chart/65202>\
**Category:** Kibana\
**Created:** [November 7, 2016, 10:39am UTC](https://discuss.elastic.co/t/how-to-filter-certain-range-of-hours-for-each-day-in-bar-chart/65202 "2016-11-07T10:39:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [November 7, 2016, 10:39am UTC](https://discuss.elastic.co/t/how-to-filter-certain-range-of-hours-for-each-day-in-bar-chart/65202/1 "2016-11-07T10:39:05Z")

</div>

I have a requirement where I need to filter out the certain hours with in the day with bar chart.

So, for example , if I search from 2016.10.01 00:00:00Z to 2016.10.06 00:00:00Z in time filter and if create a filter like 00:00 - 01:00 for each day, I expect kibana to return counts for 00:00 - 01:00 for every day.

```
Time range Counts
2016.10.01 00:00 4
2016.10.02 00:00 5
2016.10.03 00:00 1
2016.10.04 00:00 2
2016.10.05 00:00 4

```

This seems to be possible only using "now" using date range but I want to dynamically calculate from the time filter in visualization.

Is this possible?

---

<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:** [November 7, 2016, 7:38pm UTC](https://discuss.elastic.co/t/how-to-filter-certain-range-of-hours-for-each-day-in-bar-chart/65202/2 "2016-11-07T19:38:20Z")

</div>

I would look into using a "Scripted field". In the script, extract the hour (e.g. 1.00-2.00am, 2.00-3.00am, ...) from the timestamp field of each log. Then, you can filter on the value of the scripted field.

You'll need Kibana 5, which allows you to write a scripted field in Painless, a scripting language similar to Groovy.

[https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html)  
[https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)

---

<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:** [December 5, 2016, 7:38pm UTC](https://discuss.elastic.co/t/how-to-filter-certain-range-of-hours-for-each-day-in-bar-chart/65202/3 "2016-12-05T19:38:20Z")

</div>

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