# Add new values to the field if not available

**URL:** <https://discuss.elastic.co/t/add-new-values-to-the-field-if-not-available/266881>\
**Category:** Kibana\
**Created:** [March 11, 2021, 4:54am UTC](https://discuss.elastic.co/t/add-new-values-to-the-field-if-not-available/266881 "2021-03-11T04:54:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shashankdevaraj](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Shashankdevaraj](https://discuss.elastic.co/u/Shashankdevaraj)\
**Post date:** [March 11, 2021, 4:54am UTC](https://discuss.elastic.co/t/add-new-values-to-the-field-if-not-available/266881/1 "2021-03-11T04:54:11Z")

</div>

I am splitting the rows on a field called names, if some names are not available in a given time frame I want to add it and display NA across other columns. Please help.

Example table:  
name country state  
n1 c1 s1 --- available  
n2 c2 s2 --- available  
n3 NA NA ---- n3 not available

here n3 is not present, but I want to display it saying not available/present

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/4/34c17a7076a12ce4dd5e6c1c63bc3f69a914ac2a.png)

---

<div class="post-metadata">

**Author:** ![mikecote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikecote/32/58549_2.png) [@mikecote](https://discuss.elastic.co/u/mikecote)\
**Post date:** [March 29, 2021, 3:35pm UTC](https://discuss.elastic.co/t/add-new-values-to-the-field-if-not-available/266881/2 "2021-03-29T15:35:45Z")

</div>

Hi,

This should be achievable with a [script field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) on the index pattern. Something like below should do the trick!

```auto
if(doc['vendor_name'] == null) {
    return 'N/A';
} else {
    return doc['vendor_name'].value;
}

```

---

<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:** [April 26, 2021, 3:36pm UTC](https://discuss.elastic.co/t/add-new-values-to-the-field-if-not-available/266881/3 "2021-04-26T15:36:08Z")

</div>

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