# Handle null values from inuput

**URL:** <https://discuss.elastic.co/t/handle-null-values-from-inuput/156862>\
**Category:** Logstash\
**Created:** [November 15, 2018, 1:07pm UTC](https://discuss.elastic.co/t/handle-null-values-from-inuput/156862 "2018-11-15T13:07:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hvarun](https://avatars.discourse-cdn.com/v4/letter/h/b77776/32.png) [@hvarun](https://discuss.elastic.co/u/hvarun)\
**Post date:** [November 15, 2018, 1:07pm UTC](https://discuss.elastic.co/t/handle-null-values-from-inuput/156862/1 "2018-11-15T13:07:32Z")

</div>

I am using http as my source and as a first operation in filter, renaming the incoming columns as shown below for a column

> mutate{  
> add\_field =\> {"AccID" =\> "%{variable}"}  
> }  
> when i insert this into target,

i see column value to be inserted as **"%{variable}"** itself for rows with no value for AccID.

also in certain cases, response doesnt return certain columns based on the http URL defined and we get an error pointing to invalid number as it inserts the above variable into number column in database .

how can this be handled as we need to make sure to insert this as null in case the above scenarios occur

---

<div class="post-metadata">

**Author:** ![tamara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tamara/32/47095_2.png) [@tamara](https://discuss.elastic.co/u/tamara)\
**Post date:** [November 17, 2018, 12:54pm UTC](https://discuss.elastic.co/t/handle-null-values-from-inuput/156862/2 "2018-11-17T12:54:01Z")

</div>

Hi,

You should add an if clause like this:

```
  if [dimensions][0] {
    mutate { 
     add_field => {"AccID" => "%{rowid[dimensions][0]}"}
    }
  }

```

I am assuming that **rowid** is not a variable but a static field otherwise it should be between **[]** as well.

---

<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 15, 2018, 12:54pm UTC](https://discuss.elastic.co/t/handle-null-values-from-inuput/156862/3 "2018-12-15T12:54:05Z")

</div>

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