# Hide weekends for date histogram field in time series in graph

**URL:** <https://discuss.elastic.co/t/hide-weekends-for-date-histogram-field-in-time-series-in-graph/305434>\
**Category:** Kibana\
**Created:** [May 23, 2022, 8:14pm UTC](https://discuss.elastic.co/t/hide-weekends-for-date-histogram-field-in-time-series-in-graph/305434 "2022-05-23T20:14:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![monilgangar](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@monilgangar](https://discuss.elastic.co/u/monilgangar)\
**Post date:** [May 23, 2022, 8:14pm UTC](https://discuss.elastic.co/t/hide-weekends-for-date-histogram-field-in-time-series-in-graph/305434/1 "2022-05-23T20:14:16Z")

</div>

Our application runs between Monday to Friday... and not on Saturday and Sunday.  
We are creating a chart in Kibana and using the date histogram field for time series.  
It is showing the weekends as well in the graph. somehow we want to hide weekends in the chart.

Note: The data stored in Elasticsearch is only in weekdays. i.e. Monday to Friday.

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

Kindly let us know if there is a way to do that in Kibana charts.

---

<div class="post-metadata">

**Author:** ![ghudgins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ghudgins/32/138532_2.png) [@ghudgins](https://discuss.elastic.co/u/ghudgins)\
**Post date:** [May 23, 2022, 9:23pm UTC](https://discuss.elastic.co/t/hide-weekends-for-date-histogram-field-in-time-series-in-graph/305434/2 "2022-05-23T21:23:52Z")

</div>

this is a workaround at best but could be an interesting option to try. Longer term answer below

Use a runtime field to emit the date as a string at the right granularity with the weekend logic. Use "Top Values" and rank by alphabetical

```auto

ZonedDateTime input = doc['@timestamp'].value;

String output = input.format(DateTimeFormatter.ofPattern('yyyy-mm-dd'));

emit(output);

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/8/7828cc108ca3a9e96e4f8497f9e636d14a76ad43.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/8/78423515f9c8e098da5ed070aa852f782c58df3c.jpeg)

I have groomed the existing request for this and added a quote / screenshot from this discussion for the longer term fix. [[Lens] Time series only for weekdays · Issue #2942 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/2942) - I agree we should have native support for this in the date histogram.

---

<div class="post-metadata">

**Author:** ![monilgangar](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@monilgangar](https://discuss.elastic.co/u/monilgangar)\
**Post date:** [May 24, 2022, 12:54am UTC](https://discuss.elastic.co/t/hide-weekends-for-date-histogram-field-in-time-series-in-graph/305434/3 "2022-05-24T00:54:51Z")

</div>

I tried the workaround you have provided but it didn't work.

The data in the index is large, so it is taking a lot of time to compute top 100 values from timestamp-keyword.  
I have changed the top 100 to top 7 as well but the chart refresh is taking around 2-3 mins for computing the values.

This solution will not work for me.

When I again reverted to date histogram, I am getting the results in 4-5 seconds.

Do let me know if there is any other approach for solving this.

- Thanks

**Note:** Minor change in the Date Time pattern you have provided. it needs to be changed from **yyyy-mm-dd** to **yyyy-MM-dd**. (Though solution didn't fit for me). I am adding as a note here if someone wants to try it out.

---

<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, 2022, 12:55am UTC](https://discuss.elastic.co/t/hide-weekends-for-date-histogram-field-in-time-series-in-graph/305434/4 "2022-06-21T00:55:48Z")

</div>

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