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

Alteryx Designer Desktop Discussions

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

Truncating a decimal value

aka_ash
8 - Asteroid

I am wanting to truncate decimal values to 1 decimal place.

I do not want the value to have rounding applied so ToString() and the Fixed Decimal will not work for me.

 

Is there a way to this using a formula?

 

Some sample data and output below:

Data 1 
12.12312.1
0.8970.8
23.7723.7
1.556391.5
0.230.2

 

Thanks,

Ash

10 REPLIES 10
Qiu
21 - Polaris
21 - Polaris

@aka_ash 
It is like Round down right?

CaptureR2.PNG

randreag
11 - Bolide

hi @aka_ash 

 

I think your best option is create a new field set to fixdecimal 

 

I hope it helps

aka_ash
8 - Asteroid

Thanks @Qiu and @randreag 

 

The Floor formula rounding down is achieving the truncation i am looking for.

Qiu
21 - Polaris
21 - Polaris

@aka_ash 

Glad to help and thank you for the accept mark.😁

aka_ash
8 - Asteroid

Would it be possible to achieve the same using a Regex formula?

Qiu
21 - Polaris
21 - Polaris

@aka_ash 

You mean RegEx tool?

CaptureR3.PNG

aka_ash
8 - Asteroid

Hi @Qiu ,

I meant the regex_replace formula, but i can see that the Parse also works, Thanks for that

 

 

aka_ash
8 - Asteroid

Hi @Qiu.

 

One thing i did not take account of is negative numbers.

 

Looks like the Floor formula changes the value of the first decimal as it rounds down, the Regex Parse removes the negative indicator.

 

Is there a way to get the below?

 

Data 1Output
12.12312.1
-0.897-0.8
23.7723.7
-1.55639-1.5
0.230.2
-23.421-23.4

 

Thanks in advance,

 

Qiu
21 - Polaris
21 - Polaris

@aka_ash 

Sure

CaptureT2-2.PNG

Labels