# Display another field as the result of a Lens formula

**URL:** <https://discuss.elastic.co/t/display-another-field-as-the-result-of-a-lens-formula/370932>\
**Category:** Kibana\
**Tags:** lens\
**Created:** [November 22, 2024, 7:56am UTC](https://discuss.elastic.co/t/display-another-field-as-the-result-of-a-lens-formula/370932 "2024-11-22T07:56:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snicoll](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/snicoll/32/20285_2.png) [@snicoll](https://discuss.elastic.co/u/snicoll)\
**Post date:** [November 22, 2024, 7:56am UTC](https://discuss.elastic.co/t/display-another-field-as-the-result-of-a-lens-formula/370932/1 "2024-11-22T07:56:10Z")

</div>

Hello,

Assume an index which contains entries with a version field, something like:

```json
"version": {
  "properties": {
    "id": {
      "type": "keyword"
    },
    "major": {
      "type": "keyword"
    },
    "minor": {
      "type": "keyword"
    },
    "number": {
      "type": "long"
    }
  }

```

In a table I would like to show for the current aggregation the "lowest" version. To do that I've created that "number" field that's a padded format of the version.

For instance version "1.3.12" is "10312" and 2.23.1 is "22301". This way I can easily apply a `min(version.number)`.

However, I want to display the `version.text` as the result, not `version.number`.

How do I do that?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 22, 2024, 8:55am UTC](https://discuss.elastic.co/t/display-another-field-as-the-result-of-a-lens-formula/370932/2 "2024-11-22T08:55:43Z")

</div>

Bonjour Stéphane 😉

I don't think you can do that in a Lens data table, ie when aggregating data with a min metric. Because the min metric implies a calculation of a numerical value and not a "give me the document where x is the min of the dataset".

I was trying this morning to POC around ES|QL to see if we have a solution for this and for now the `INLINE STATS` feature is not available. There will be some new features in ES|QL that would allow such computations.

But while digging around this, I found that ES|QL has now support to `TO_VERSION` which is super handy IMO in your case.

Have a look at:

```auto
DELETE test 
PUT test
{
  "mappings": {
    "properties": {
      "version": {
        "type": "keyword"
      }
    }
  }
}
PUT test/_doc/1
{
  "version": "1.12.3"
}
PUT test/_doc/2
{
  "version": "2.23.4"
}

```

You can run something like:

```auto
FROM test 
| EVAL v = TO_VERSION(version)
| STATS min = MIN(v)
| LIMIT 10

```

Which gives you:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/1/212349a2c456114c1d3012bdeba6bbafcd5f7a83.png)

Not sure it helps, but that's an idea 😉
