# Howto convert this to a number?

**URL:** https://discuss.elastic.co/t/howto-convert-this-to-a-number/161760
**Category:** Logstash
**Created:** [December 20, 2018, 10:16pm UTC](https://discuss.elastic.co/t/howto-convert-this-to-a-number/161760 "2018-12-20T22:16:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ritten](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritten/32/38483_2.png) [@Ritten](https://discuss.elastic.co/u/Ritten)
#### Post date: [December 20, 2018, 10:16pm UTC](https://discuss.elastic.co/t/howto-convert-this-to-a-number/161760/1 "2018-12-20T22:16:13Z")

</div>

Hi  
I have a field in Logstash that I can't convert. The field value is DKK82,334.25 and is a string that I need to convert into a number.  
I start by removing the DKK, and then I have tried to convert it into float and float\_eu, but when I do that the value turns into 0.0.  
I use gsub to remove the " DKK" and replace with a "" and after that I use convert but the value is just the 0.0  
Any help will be appreciated.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [December 25, 2018, 6:19am UTC](https://discuss.elastic.co/t/howto-convert-this-to-a-number/161760/2 "2018-12-25T06:19:50Z")

</div>

The order different settings are executed in within a single mutate filter is not necessarily the order they are defined, so it is good practice to do this in distinct steps:

```auto
input {
  generator {
    lines => ['DKK82,334.25']
    count => 1
  } 
} 

filter {
  mutate {
    gsub => ["message", "DKK", ""]
  }
  mutate {
    convert => {
      "message" => "float"
    }
  }
}

output {
  stdout { codec => rubydebug }
}

```

---

<div class="post-metadata">

### Author: ![Ritten](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritten/32/38483_2.png) [@Ritten](https://discuss.elastic.co/u/Ritten)
#### Post date: [December 28, 2018, 12:41am UTC](https://discuss.elastic.co/t/howto-convert-this-to-a-number/161760/3 "2018-12-28T00:41:19Z")

</div>

Thanks. It got me in the right direction and it works now.

---

<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: [January 25, 2019, 12:41am UTC](https://discuss.elastic.co/t/howto-convert-this-to-a-number/161760/4 "2019-01-25T00:41:21Z")

</div>

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