How to get part of a number before a decimal point

Given a decimal number like “123.456” how can I get only the part before the decimal point (in this case “123”) without any rounding etc. being applied?

Use the find() function.

"230.22398, 12.3480".find(/(\d+)\./)
returns the array of all the number without decimals.
[ "230.", "12." ]

For the same with one number:
"230.22398".find(/(\d+)\./)[0]
returns
"230."

Using Edit Cells -> Transforms:
value.find(/(\d+)\./)

@ostephens : shouldn't the parentheses remove the dot?

Regards, Antoine

Another way to approach the problem is to convert your column of Numbers to Strings using the dropdown column menu.
Then use something like
value.split(".")[0]
which will split the String at the . period character and yield 2 parts where you only want to return the first part [0] , the one before the decimal.
Then optionally convert the column of transformed Strings back into Numbers.

1 Like