# How to filter dashboard by field maximum value

**URL:** <https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129>\
**Category:** Kibana\
**Created:** [July 15, 2025, 7:45am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129 "2025-07-15T07:45:18Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 15, 2025, 7:45am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/1 "2025-07-15T07:45:19Z")

</div>

Hi all.

This seems easy enough, but I'm being unable to achieve it, and don't find an answer on internet.

In our use case, we've built a dashboard with several lens graphs. Users reach that dashboard through a shared link where we include some filter parameters in a querystring, so, depending where they click, they reach the dashboard pre-filtered by their click selection.

Now, we want to add to our querystring a new parameter to filter data by default for the last year. We have a field with the year on our index, and we just need to add a filter on the querystring to filter by this year field maximum value.

We cannot use a date filter because yearly data are loaded mid year more or less, so we want that while data from 2025 is not available, users reach the dashboard automatically filtered by 2024, and the moment 2025 data is available, they reach it filtered by 2025.

I'm struggling to achieve this simple filter directly on the dashboard, previously to transfer it to the querystring that we add to the links

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [July 17, 2025, 2:11pm UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/2 "2025-07-17T14:11:50Z")

</div>

Hi @PMF,

To confirm, is the year being passed via the query string parameter on the URL? Or are you wanting to calculate the last year and they pass it through? Is this an embedded dashboard or a direct link that users click on to get to the dashboard?

---

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 18, 2025, 7:06am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/3 "2025-07-18T07:06:47Z")

</div>

Hi Carly.

Thanks for replying. The idea is to embed the filter in the querystring, but we don't know the desired value on the moment we create the link, we need to somehow calculate it or insert a function that calculates it (max(year)?) inside the querystring.

I will explain to you our use case:

We work for the town council, and have a GIS with geographical data of the city. Users that access to those maps can click over every different neighborhood and get redirected to a elastic dashboard where population statistical data are showed, the link filters that data in advance by the neighborhood where users have clicked. Now we want to add to that filtered links something that allows us to assure that users see the lattest data available (those statistical data loads yearly).

Please, don't hesitate in asking for more information if what we are trying is not clear enough.

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [July 21, 2025, 6:23am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/4 "2025-07-21T06:23:44Z")

</div>

Hello @PMF

Until we wait for response from Carly, i do not see how we can dynamically update the dashboard with the latest year filter.

As per me below is 1 work around , what if we add a filter on field year & the user will be able to see the available options of year for the dashboard. So if the year 2025 data is available they will see that value in the slider (min-max). From this slider they can set the maximum value?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5b1315eea488c95afa69dc3a05795504b4f12a12.png)

Thanks!!

---

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 21, 2025, 7:37am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/5 "2025-07-21T07:37:32Z")

</div>

Welcome to the topic, Tortoise, and thank you for your idea.

Sadly, we already have a filtering component on the dashboard by year. But we've seen that users tend to miss new data when it's suddenly available, and they tend to stick whith the default filtered status, whatever it will be. This is the reason why we are looking for alternatives.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [July 21, 2025, 8:49am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/6 "2025-07-21T08:49:22Z")

</div>

Yeah @Tortoise's suggestion to include a filter for the year value based on the field is probably the easiest option. You can then specify the value in the URL using the Kibana query parameters [as discussed here](https://discuss.elastic.co/t/kibana-g-and-a-parameters-in-the-dashboards-url-string/264642).

If you want the value to be completely dynamically generated this would be easy if you were embedding the dashboard as you could probably have logic in JavaScript to generate the year.

---

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 22, 2025, 8:40am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/7 "2025-07-22T08:40:38Z")

</div>

Do I assume, then, that there is no way to query a field by its maximum value?

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [July 22, 2025, 10:30am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/8 "2025-07-22T10:30:21Z")

</div>

You could use a max aggregation on a runtime field:

> **[Max aggregation | Reference](https://www.elastic.co/docs/reference/aggregations/search-aggregations-metrics-max-aggregation)**
>
> A single-value metrics aggregation that keeps track and returns the maximum value among the numeric values extracted from the aggregated documents. Computing...

---

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 22, 2025, 10:48am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/9 "2025-07-22T10:48:12Z")

</div>

Thank you, this seems promising, probably we'll be able to stablish a runtime field containing the maximum year value and querying it.

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [July 22, 2025, 11:13am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/10 "2025-07-22T11:13:43Z")

</div>

Maybe I am being slow today, but how will this work?

> [@PMF](#):
>
> we just need to add a filter on the querystring to filter by this year field maximum value

Whats going to be the filter? The docs have the example below, the runtime field is `price.adjusted` and that is aggregated into `max_price`. The runtime field is just a function from the individual document.

```auto
POST /sales/_search
{
  "size": 0,
  "runtime_mappings": {
    "price.adjusted": {
      "type": "double",
      "script": """
        double price = doc['price'].value;
        if (doc['promoted'].value) {
          price *= 0.8;
        }
        emit(price);
      """
    }
  },
  "aggs": {
    "max_price": {
      "max": { "field": "price.adjusted" }
    }
  }
}

```

> [@PMF](#):
>
> probably we'll be able to establish a runtime field containing the maximum year value

How precisely?

---

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 22, 2025, 11:33am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/11 "2025-07-22T11:33:26Z")

</div>

Hi Kevin, welcome to the topic.

I'm trying to figure it right now, but I'm thinking that if I can stablish an aggregation like the max\_price of your example, I should be able to query through the url with something like:

`https://.....?_g=(filters:!((query:(match_phrase:(price.adjusted:max_price)))))`

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [July 22, 2025, 11:44am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/12 "2025-07-22T11:44:18Z")

</div>

Understood and good luck. But please let us know if it works. Great if it does, it'll add a new tool to the toolbox. But I am dubious, though I hope I am also wrong to be dubious.

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [July 28, 2025, 2:23pm UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/13 "2025-07-28T14:23:29Z")

</div>

And? Were you able to get it to work ?

---

<div class="post-metadata">

**Author:** ![PMF](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@PMF](https://discuss.elastic.co/u/PMF)\
**Post date:** [July 29, 2025, 7:00am UTC](https://discuss.elastic.co/t/how-to-filter-dashboard-by-field-maximum-value/380129/14 "2025-07-29T07:00:41Z")

</div>

Sadly not yet. I'd to turn to other matters before exhausting every possibility I had in mind. So... I didn't threw the towel yet with this, and will probably pass some time before I can spend time on it. But not fear, if I finally manage to get it to work I'll post the result here.
