# Extraxt data from a strin in a shown in a data table

**URL:** <https://discuss.elastic.co/t/extraxt-data-from-a-strin-in-a-shown-in-a-data-table/368439>\
**Category:** Kibana\
**Created:** [October 8, 2024, 11:29am UTC](https://discuss.elastic.co/t/extraxt-data-from-a-strin-in-a-shown-in-a-data-table/368439 "2024-10-08T11:29:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhav\_dahmival](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_dahmival/32/138174_2.png) [@vaibhav\_dahmival](https://discuss.elastic.co/u/vaibhav_dahmival)\
**Post date:** [October 8, 2024, 11:29am UTC](https://discuss.elastic.co/t/extraxt-data-from-a-strin-in-a-shown-in-a-data-table/368439/1 "2024-10-08T11:29:59Z")

</div>

I was creating a dashboard, when i tried creating a data table selected the field i want to add. But i only wanted the first 3 digits from that string. Could you guys help me with it on how to do it. there were some solutions available but did not work.

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

---

<div class="post-metadata">

**Author:** ![SamehSaeed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samehsaeed/32/145262_2.png) [@SamehSaeed](https://discuss.elastic.co/u/SamehSaeed)\
**Post date:** [October 9, 2024, 7:46am UTC](https://discuss.elastic.co/t/extraxt-data-from-a-strin-in-a-shown-in-a-data-table/368439/2 "2024-10-09T07:46:58Z")

</div>

If I understand you correctly, you can create a runtime field to extract the specified string, then visualize that field.  
Go to Stack management ==\> Data Views ==\> select your data view then create a runtime field

it should look like this :

```auto
if (doc['MSAN.keyword'].size() != 0) {
    String msan= doc['MSAN.keyword'].value;
    if (msan.length() >= 3) {
        return msan.substring(0, 3);
    }
}
return null;

```
