In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!
Free Trial

Alteryx Designer Desktop Discussions

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

Formula for Triming a String

KmbrlyPC
8 - Asteroid

I have some values with decimals that I am needing to trim off completely in order for a join to work properly. How do I remove the decimal and any numbers that follow? For example I have values 2.1, 2.2, 2.3. I just want it to display a "2". I have other numbers in that same column that are whole numbers that do not need trimmed.

3 REPLIES 3
apathetichell
19 - Altair

Are 2.1 etc all in the same field? Are they numbers or strings? for numbers try round([field],1)

 

for strings try tostring(round(tonumber([field],1)))

 

and for mixed info try:

regex_replace([field],"(\d+)\..*","$1")

Treyson
13 - Pulsar
13 - Pulsar

If they are in the same field and you don't need to round up, like 2.6 needs to be 2 instead of 3, I have attached a solution that uses the text to columns tool and talks about the miracle of the "split to rows" option, which is a common design strategy with a mixed bag of delimiters in a single field.

Treyson Marks
Managing Partner
DCG Analytics
fmvizcaino
17 - Castor
17 - Castor

Hi @KmbrlyPC ,

 

You can use a select tool and change the column format to integer, that will automatically round your number.

If you would like to get your values without rounding, you can use the floor function to achieve that.

 

Best,

Fernando Vizcaino

 

Labels
Top Solution Authors