# Put Max date filter by default in Kibana

**URL:** <https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346>\
**Category:** Kibana\
**Created:** [May 2, 2019, 11:10am UTC](https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346 "2019-05-02T11:10:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![suhasgupta1](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@suhasgupta1](https://discuss.elastic.co/u/suhasgupta1)\
**Post date:** [May 2, 2019, 11:10am UTC](https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346/1 "2019-05-02T11:10:02Z")

</div>

Hi All,

My question is related to

> [@Filtering on date = max\_date](https://discuss.elastic.co/t/filtering-on-date-max-date/28979):
>
> Short version: How do I create a "saved search" that filters based on the most recent date available? Long version: I have a daily PIG job that updates ES based on the today's date. The problem is that sometimes the job fails and no data is updated for several days. So I want Kibana to filter based only on the data with the latest date, regardless of whether it's from today or a week ago. Is it possible and if so, how? From what I've read [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html), I can retrieve the max "date" value with somethin…

Is that possible today?

I want to put filter by default in Kibana dashboard which will always select max date from date field. Is it possible with Query DSL if yes kindly tell how ?

Thanks & Regards  
Suhas Gupta

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [May 2, 2019, 10:43pm UTC](https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346/2 "2019-05-02T22:43:37Z")

</div>

I have a couple thoughts on how this could be accomplished.

Canvas pipelines support subexpressions, so you should be able to accomplish this with something like the following:

`essql {string "SELECT .... WHERE timestamp <=" {esdocs <get latest document> | getCell <timestamp field>} }`

The Canvas pipeline expressions are also coming to Kibana proper and will be soon the bases of all visualizations which will make things like this much easier in the future.

Another, possibly easier solution is to alter the dasboard/visualization as part of your daily job. Here is the API for the underlying data Kibana persists: [https://www.elastic.co/guide/en/kibana/current/saved-objects-api.html](https://www.elastic.co/guide/en/kibana/current/saved-objects-api.html).

---

<div class="post-metadata">

**Author:** ![suhasgupta](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@suhasgupta](https://discuss.elastic.co/u/suhasgupta)\
**Post date:** [May 13, 2019, 5:09pm UTC](https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346/3 "2019-05-13T17:09:28Z")

</div>

Hi Tylersmalley,

Thank you for replying, I am not pro in elasticsearch or kibana. Could you kindly tell if I can write this essql in query DSL in Filter in kibana or where can I use this query.

Thanks  
Suhas

---

<div class="post-metadata">

**Author:** ![suhasgupta1](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@suhasgupta1](https://discuss.elastic.co/u/suhasgupta1)\
**Post date:** [May 20, 2019, 6:55am UTC](https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346/4 "2019-05-20T06:55:27Z")

</div>

Hello @tylersmalley, Kindly guide how to use this query, can I write this query in filter in DSL query section of kibana, Or I have to write this query at some other location.

Thanks & Regards  
Suhas Gupta

---

<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 17, 2019, 6:55am UTC](https://discuss.elastic.co/t/put-max-date-filter-by-default-in-kibana/179346/5 "2019-06-17T06:55:38Z")

</div>

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