# IF with Mutate Filter

**URL:** https://discuss.elastic.co/t/if-with-mutate-filter/124386
**Category:** Logstash
**Created:** [March 17, 2018, 5:02am UTC](https://discuss.elastic.co/t/if-with-mutate-filter/124386 "2018-03-17T05:02:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 17, 2018, 5:02am UTC](https://discuss.elastic.co/t/if-with-mutate-filter/124386/1 "2018-03-17T05:02:24Z")

</div>

I have a couple fields that will come in one of two values, `r` or `s`. I'd like to convert them to `Relaxed` or `Strict` as they come, but there may be instances where the field has no value. Is there a more efficient way than writing two `if` statements for each field?

Disregard, realized I could just use mutate's gsub function.

---

<div class="post-metadata">

### Author: ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)
#### Post date: [March 17, 2018, 5:48am UTC](https://discuss.elastic.co/t/if-with-mutate-filter/124386/2 "2018-03-17T05:48:36Z")

</div>

Or the [translate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html) filter 🙂

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 17, 2018, 5:51am UTC](https://discuss.elastic.co/t/if-with-mutate-filter/124386/3 "2018-03-17T05:51:44Z")

</div>

> [@yaauie](#):
>
> Or the [translate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html) filter 🙂

Ooooo, I hadn't looked at translate before...that looks neat. I'll have to keep that in my back pocket.

---

<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 14, 2018, 5:52am UTC](https://discuss.elastic.co/t/if-with-mutate-filter/124386/4 "2018-04-14T05:52:07Z")

</div>

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