Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Nou pe simpatie: mariana_n23 din Brasov
 | Femeie 24 ani Brasov cauta Barbat 29 - 52 ani |
|
|
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
|
| pus acum 3 zile#1 |
TRaPModerator
Postari: 963
|
|
I received some amounts in an e-mail table and they have multiple spaces before the amounts (but depending on the amounts, so not fixed number of spaces), thousands separators (dots), and might as well have commas as separators or other artifacts. I'm looking for a LAMBDA function to clean these and just get the numbers (with decimals if applicable, so separators could be . and decimals , or the other way around).
The following LAMBDA function which I saved as CLEANNR cleans the extra spaces (variable number of them), thousands separators that due to the spaces are not recognized as such or due to Regional Formatting are returning errors.
The formula considers decimals and they are not lost.
=LAMBDA(rng; MAP(rng; LAMBDA(x; LET( s;TEXTJOIN("";TRUE;IF(ISNUMBER(SEARCH(MID(x;SEQUENCE(LEN(x));1);"0123456789.,-"));MID(x;SEQUENCE(LEN(x));1);"")); neg;LEFT(s;1)="-"; n;IF(neg;MID(s;2;LEN(s));s); dots;LEN(n)-LEN(SUBSTITUTE(n;".";"")); commas;LEN(n)-LEN(SUBSTITUTE(n;",";"")); lastDot;IFERROR(FIND("@";SUBSTITUTE(n;".";"@";dots));0); lastComma;IFERROR(FIND("@";SUBSTITUTE(n;",";"@";commas));0); lastSep;MAX(lastDot;lastComma); digitsAfter;LEN(n)-lastSep; isDecimal;AND(lastSep>0;digitsAfter<=2); clean; IF( lastSep=0; n; IF( isDecimal; SUBSTITUTE(SUBSTITUTE(LEFT(n;lastSep-1);".";"");",";"")&"."&MID(n;lastSep+1;99); SUBSTITUTE(SUBSTITUTE(n;".";"");",";"") ) ); IFERROR(IF(neg;-1;1)*NUMBERVALUE(clean;".";",");NA()) ) ) )) |
Source: ChatGPT
|
|
| |
|