Forum Discussion
Formula extract digits
- Oct 18, 2023
The terms with the embedded character that is not a decimal separator (radix) could be separated using
= NUMBERVALUE(TEXTBEFORE(data, ".",,,1))
where the final 1 ensures that, in the absence of the separator, the entire string is returned. The integer part of numbers with a decimal separator could then be returned using INT.
= INT(NUMBERVALUE(TEXTBEFORE(data, ".",,,1)))
Alternatively you could test to distinguish numbers from text strings and apply different rules according to the case.
= IF(ISNUMBER(data), INT(data), NUMBERVALUE(TEXTBEFORE(data, ".")) )
- PeterBartholomew1Oct 18, 2023Silver Contributor
The terms with the embedded character that is not a decimal separator (radix) could be separated using
= NUMBERVALUE(TEXTBEFORE(data, ".",,,1))
where the final 1 ensures that, in the absence of the separator, the entire string is returned. The integer part of numbers with a decimal separator could then be returned using INT.
= INT(NUMBERVALUE(TEXTBEFORE(data, ".",,,1)))
Alternatively you could test to distinguish numbers from text strings and apply different rules according to the case.
= IF(ISNUMBER(data), INT(data), NUMBERVALUE(TEXTBEFORE(data, ".")) )
- PeterBartholomew1Oct 18, 2023Silver Contributor
Afterthought:
If you have the misfortune to be using a version of Excel other than 365 (or maybe 2021), you would need to use LEFT and either trap the errors or test the data
= INT(IFERROR(LEFT(data, SEARCH(".", data) - 1), data))