Assuming you don't have excel version constraints, per the tags listed in your question. Put all the suffixes as delimiters inside {}
delimited by a comma as follow in TEXTSPLIT
, then define the conversion rules in XLOOKUP
. We use SUBSTITUTE(col, nums, "")
as input of XLOOKUP
to extract the unit of measure.
=BYCOL(A2:B4, LAMBDA(col, LET(nums, 1*TEXTSPLIT(col,{"ms","us"},,1),
units, XLOOKUP(SUBSTITUTE(col, nums, ""), {"us";"ms"},{1;1000}),
SUM(nums * units))))
The above formula converts the result to a common unit of microseconds (us
), i.e. to the lower unit, so milliseconds get converted by multiplying by 1000
. If the unit of measure was not found it returns #N/A
, it can be customized by adding a fourth parameter to XLOOKUP
. If you want the result in milliseconds, then replace: {1;1000}
with {0.001;1}
or VSTACK(10^-3;1)
for example.

If you would like to have everything in seconds, you can use the trick of using power combined with the XMATCH
index position, to generate the multiplier. I took the idea from this question: How to convert K, M, B formatted strings to plain numbers?, check the answer from @pgSystemTester (for Gsheet, but it can be adapted to Excel). I included nanoseconds too.
=BYCOL(A2:B4,LAMBDA(col,LET(nums,1*TEXTSPLIT(col,{"ms","us"},,1),
units, 1000^(-IFERROR(XMATCH(RIGHT(col,2), {"ms";"us";"ns"}),0)),
SUM(nums * units))))
Under this approach, seconds is the output unit, because it is not part of the XMATCH
lookup_array
input argument, the multiplier will be 1
(as a result of 1000^0
), so no units or seconds (s
) will be treated the same way.
Notes:
- In my initial version I used
INDEX
, but as @P.b pointed out in the comments, it is not really necessary to remove the second empty column, instead, we can use the ignore_empty
input argument from TEXTSPLIT
. Thanks
- You can use
TEXTBEFORE
instead of TEXTSPLIT
, as follows: TEXTBEFORE(A2:A4,{"ms","us"})