Easy Calculator

How can i sum a list that i all ready copy to my clipboard, but i need to replace from "." to "," to have a number right? not a text.

i know that i can {=split({clipboard}, "\n")[1]}{key: tab}{=split({clipboard}, "\n")[2]}{key: tab}{=split({clipboard}, "\n")[3]}{key: tab}...
but how can i sum them with the replace funtion and make it work no matter how many elements i add to clipboard (10 max) with $dd.ddd / $ddd.ddd / $d.ddd.ddd. It seems to be easy but I can't make it.

Clipboard list
$285.600
$196.350
$52.955
$24.930

Here is an example:

{=sum(map(split({clipboard}, "\n"), v -> replace(replace(v, "$", ""), ".", "")))}

This snippet will remove dots and dollar signs before summing up all the numbers. The output will be also a number without dots inside.

1 Like

Thanks you so much, quick question. If i want to add one more replace funtion ".", "" to the original how would it be? sum(map(split({clipboard}, "\n"), v -> replace(replace(v, "$", ""),".", "")))

Do you mean removing all the dots from the clipboard content? You could do it like this:

{=sum(map(split(replace({clipboard}, ".", ""), "\n"), v -> replace(v, "$", "")))}

No, what i mean is removing the "comas" too. In Chile we use as thousands separator the dots not the comas.

$1.477.980
$147,798
[Error - Cannot convert "147,798" to a number.]
=$1.625.778

You can do it like this:

{=sum(map(split(replace(replace({clipboard}, ".", ""), ",", ""), "\n"), v -> replace(v, "$", "")))}

i have a problem with my window laptop cliboard, it looks that the clipboard change the format to text so mi snippets it dosnt reconice the number format to make the sum "ERROR - Can not convert "" to a number" can you help me?

Sure @Nikolas_Torres_Niko,

Please paste content of your clipboard here. You can use the following snippet to see what you get in Text Blaze:

{clipboard}

I assume that we're talking about the last snippet that I posted on Nov'22, if not please also describe what are you trying to achieve.

Same thing! im trying to sum this list for example.

$285.600
$196.350
$52.955
$24.930

but it doesnt reconice the right format "number" to make the sum funtion. It takes as text, but it is just in window OS; in IOS or Chrome OS it works perfect. So my clipboard change the format i guess.

its right same nov 22 post ! thanks you so much.

On windows newlines have different special characters representing them, try this:

{=sum(map(split(replace(replace({clipboard}, ".", ""), ",", ""), "\r\n"), v -> replace(v, "$", "")))}

I just replaced \n with \r\n, which is how usually it works on windows for newlines.

2 Likes