Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Format columns

JDong
8 - Asteroid

Hi Team,

 

I have the 2 columns in my data.

 

Price column is to be formatted with a thousand separator and on 2 decimal for all values. Example : 6.3211,00.

Average column is to be formatted as 2 decimals Ex : 0,06

 

The final field is needed as a string. 

 

 

PriceAverage
632210
  
78050
382450
335620
304400
780521
249760
  
15610
124880
241960
78050
00
1225411
  
561970
2435212
4854825
1701521
93660
93660
  
00
273180
54630
00
00
2661522
  
944410
1170740
1951282
616600
343420
515130
17951,960,23
13268,840,17
5463,640,07
21074,040,27
41367,560,53
28098,720,36
5463,640,07
11707,80,15
3902,60,05
35903,920,46
24976,640,32
37464,960,48
8360150 

 

Please advise. Also to note the column already has different values but need to format and make them consistent. Thanks

9 REPLIES 9
PhilipMannering
16 - Nebula
16 - Nebula

Hey @JDong 

 

This seems like an overkill way of doing it, but I think it works,

PhilipMannering_0-1618480089717.png

 

JDong
8 - Asteroid

Thanks @PhilipMannering 

 

The expanded decimals have actual values in the dataset. So it always should not round to ,00 but use the decimal points to arrive at relevant values

AdamR_AYX
Alteryx Alumni (Retired)

I think this formula does what you want

 

ToString(ToNumber([_CurrentField_], 0, 1, ","), 2, ".", ",")

 

ToNumber parses the strings to numbers with a , for the decimal separator

 

Then ToString parses that number back to the format you want.

Adam Riley
https://www.linkedin.com/in/adriley/
JDong
8 - Asteroid

Hi @AdamR_AYX 

 

There is an error with the flow on the string conversion, could you please help !

 

Gallop_0-1618481790703.png

 

Thanks

AdamR_AYX
Alteryx Alumni (Retired)

Is this one any better?

 

What version of Alteryx are you on?

Adam Riley
https://www.linkedin.com/in/adriley/
JDong
8 - Asteroid

Hi  @AdamR_AYX 

 

Sorry still same and I use both 2019.1 and 2020.3

 

Gallop_0-1618482384189.png

 

Thanks

AdamR_AYX
Alteryx Alumni (Retired)

OK sorry just checked and this was a new feature in 2020.4

 

https://help.alteryx.com/release-notes/designer/designer-20204-release-notes

 

I can do it in one formula in previous versions. It's just an ugly formula:

 

Replace(Replace(Replace(ToString(ToNumber(Replace([_CurrentField_], ",", ".")), 2, 1),
".", "¬"),
",", "."),
"¬", ",")

 

To walk through it (from the inside out)

 

We replace , with . and then convert to a number

Then convert the number back to a string with 2 decimal places and thousand separator. But , for the thousand separator and . for decimal separator.

Then replace the . with a ¬ (temporary placeholder for this character)

Replace the , with a .

Finally replace the ¬ with a ,

 

 

Adam Riley
https://www.linkedin.com/in/adriley/
JDong
8 - Asteroid

Hi @AdamR_AYX 

 

Thanks an excellent solution...one question..when we use a multi-field tool, is it possible to replace original field values instead of creating new columns ?

AdamR_AYX
Alteryx Alumni (Retired)

Yes just uncheck this box

 

AdamR_0-1618492495837.png

 

Adam Riley
https://www.linkedin.com/in/adriley/
Labels
Top Solution Authors