Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Number formatting with multiple periods

MRoyW
8 - Asteroid

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.

10 REPLIES 10
DavidP
17 - Castor
17 - Castor

like this?

 

DavidP_0-1581499848694.png

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @MRoyW,

 

You could also achieve this within one formula tool using:

 

ToString(ReplaceChar(REGEX_Replace([Value], '^(.*)\..+$', '$1'),'.','')) + ToString(REGEX_Replace([Value], '^.*(\..+)$', '$1'))

 

image.png

 

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

demand_james
8 - Asteroid

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.

 

 

demand_james
8 - Asteroid

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 "."

 

 

DiegoParker
10 - Fireball

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.

 

DiegoParker_0-1581504211106.png

 

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

 

demand_james
8 - Asteroid

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!!

DiegoParker
10 - Fireball

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.

MRoyW
8 - Asteroid

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

MRoyW
8 - Asteroid

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

Labels