Convert string to float in transaction group

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.

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".

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… :laughing:

The zero at the end is a failover value.