# Convert string to float in transaction group

**URL:** <https://forum.inductiveautomation.com/t/convert-string-to-float-in-transaction-group/10242>\
**Category:** Ignition\
**Created:** [July 17, 2015, 4:41pm UTC](https://forum.inductiveautomation.com/t/convert-string-to-float-in-transaction-group/10242 "2015-07-17T16:41:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [July 17, 2015, 4:41pm UTC](https://forum.inductiveautomation.com/t/convert-string-to-float-in-transaction-group/10242/1 "2015-07-17T16:41:44Z")

</div>

I have a transaction group logging a string from a weigh scale. The data comes back as “109.55 lb Under” I want to strip out “lb Under” and just log the weight.

I have a query that will select the data like I need but would rather just put the data in the table like I need it to begin with.

```auto
select avg(substring_index(`weight`,' ',5)) as average from line_2_pallet
```

Is there an expression script that can maybe do this? The string coming back will always have the same ending pattern " lb Under".

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 17, 2015, 5:23pm UTC](https://forum.inductiveautomation.com/t/convert-string-to-float-in-transaction-group/10242/2 "2015-07-17T17:23:15Z")

</div>

It’ll be something like this:

toFloat(left(stringValue, indexOf(stringValue, " ")))

Replace stringValue with whatever your input is

EDIT: Actually, all you need is:

toFloat(stringValue, 0)

It will stop at the first thing that doesn’t represent a digit or decimal place. That’s what I get for overthinking it… 😆

The zero at the end is a failover value.
