# Custom fieldformat from int to string

**URL:** <https://discuss.elastic.co/t/custom-fieldformat-from-int-to-string/106682>\
**Category:** Kibana\
**Created:** [November 7, 2017, 12:17pm UTC](https://discuss.elastic.co/t/custom-fieldformat-from-int-to-string/106682 "2017-11-07T12:17:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kumpelblase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kumpelblase/32/35709_2.png) [@kumpelblase](https://discuss.elastic.co/u/kumpelblase)\
**Post date:** [November 7, 2017, 12:17pm UTC](https://discuss.elastic.co/t/custom-fieldformat-from-int-to-string/106682/1 "2017-11-07T12:17:31Z")

</div>

Hi there,

I have a bunch of documents with the attribute status, which can be an integer from 0 to 5. I now want in the visualisation instead of the numbers 0 to 5 strings for these, like 0 = New, 1 = edited, etc. I don't really know how I can achieve this. The only way I'm comming up with is to hook up a tiny webserver which does the magic. Any help how I can manage this without a webserver is apprechiated.

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [November 7, 2017, 5:34pm UTC](https://discuss.elastic.co/t/custom-fieldformat-from-int-to-string/106682/2 "2017-11-07T17:34:35Z")

</div>

You can create a scripted field to do this:

1. Click Management
2. Click Index Patterns
3. Click the desired index pattern
4. Click Scripted Fields
5. Click Add Scripted Field
6. Choose a name for the field, e.g. status\_string
7. Select string as the type
8. In the script, type something like the following:

```auto
def status = doc['status'].value;
if (status == 0) return 'New';
if (status == 1) return 'edited';
// etc.

```

Save the scripted field, and you should see it everywhere in Kibana!

---

<div class="post-metadata">

**Author:** ![kumpelblase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kumpelblase/32/35709_2.png) [@kumpelblase](https://discuss.elastic.co/u/kumpelblase)\
**Post date:** [November 8, 2017, 7:05am UTC](https://discuss.elastic.co/t/custom-fieldformat-from-int-to-string/106682/3 "2017-11-08T07:05:02Z")

</div>

Thanks, that works just fine.

---

<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:** [December 6, 2017, 7:05am UTC](https://discuss.elastic.co/t/custom-fieldformat-from-int-to-string/106682/4 "2017-12-06T07:05:35Z")

</div>

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