Summing values formatted for a different locale


A couple of year ago a user of Super User reported difficulties with summing values purporting to be Euros imported to LibreOffice Calc in CSV format.

In the Q the user does not mention the locale settings, but did write "I've used the LEFT function to get just the number part, though that still leaves me with a string." Some sample data was provided, but not its location so assuming the following:

Sample data

and , to separate thousands, . for decimal, how to determine the sum of the above text-format amounts?

Why should this post be closed?


1 answer


In LibreOffice Calc

=SUM(1*SUBSTITUTE(SUBSTITUTE(LEFT(A2:A6,LEN(A2:A6)-2),",",".")," ",""))

entered as an array formula (with Ctrl+Shift+Enter before Enter).

Will fail if the range includes blank cells.

Working outwards, the LEFT takes the contents of the 'A' cell up to and not including the character second from its right-hand end then substitutes . for ,. Another substitution, not required for the same data, removes any other (standard) spaces in the cell. This last because where comma is the decimal separator a thousands separator of a space is quite likely.

1* is applied to switch the format from Text to Numeric for the summation.


Sign up to answer this question »