Hi, I have a data set that has numbers in the form of: 2.200.000 or 3.98. Does anyone know a way of removing any way of removing the periods up until the last one, which would serve as the decimal separator?
Thanks in advance.
Solved! Go to Solution.
Hi @MRoyW,
You could also achieve this within one formula tool using:
ToString(ReplaceChar(REGEX_Replace([Value], '^(.*)\..+$', '$1'),'.','')) + ToString(REGEX_Replace([Value], '^.*(\..+)$', '$1'))
If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.
Regards,
Jonathan
This was a bit trickier then i thought.
This solution isnt the prettiest - but it does work. I tried messing around with regex counts but this was simplier.
Essentially parse the number into rows with a record id. Then used a multi-row formula tool to add the numbers together except for the final case. Then summarized to get the last value as well.
Interested as well in thoughts from the community for easier ways. Or could be a nice standard macro as I could see the case coming up from time to time.
Cool! Does this work regardless of how many "." there are?
So
2.000.000.00 = 2000000.00
AND
394 = 394
AND
3.94 = 3.94
etc
Couldnt figure how how to do the regex replace n-1 times based on a regex count of n occurences of the "."
Hi MroyW,
I have been trying to use non-regex string functions to solve some of my problems. Here is my take:
The calculation for you to copy is: Replace(Replace(ReverseString(ReplaceFirst(ReverseString([Text]),".","-")),".",""),"-",".")
Basically what this is doing is reversing the string, finding the first stop, then it changes to a dash, then get rids of all the dots, then replaces the dash for a dot and then reverses the string again.
Hope this helps If does, can I ask you to mark it as the solution? this will help other users to find it and will allow us to close the thread. Many thanks!
Best,
Diego
Nice one - had thought about doing something like this as well but couldnt figure out how to find last. Nice work to reverse it and make find last into find first!!
Thanks! I did learn this yesterday by answering things on the forums 😛 I've been trying to use less regex lately to practice the other string functions.
This works too but does not solve the problem of removing all but the last period. Also, for an oddly delimited data set then it would be cumbersome. Thanks for the idea, DavidP
Hi Jon, thank you for this. I encountered a slight problem with this: assume that a number is presented without any period, say 35000, it gets concatenated into 3500035000. Any ideas on how to fix that?
Also, I think you'll find a better solution that was posted by DiegoParker