Alert: There is a planned Community maintenance outage October 16th from approximately 10 - 11 PM PST. During this time the Alteryx Community will be inaccessible. Thank you for your understanding!

Alteryx Designer Desktop Discussions

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

Concatenate integers

parria1
8 - Asteroid

I have two fields that are year and month and are integers. I am trying to concatenate these two fields so they go display like 2020-01,2020-02, etc

 

i cannot figure out how to do this with tostring and padleft functions. i keep getting malformed function errors.

 

 

7 REPLIES 7
bpatel
Alteryx Alumni (Retired)

hi

 

You can change the data type of those two fields to strings and try this expression in the formula tool [year]+ "-"+[month].

 

hope this helps!

parria1
8 - Asteroid

how do i get the zero to populate? i want it to read 2020-01 not 2020-1

Aaron_Harter
11 - Bolide

@parria1 - check out the attached solution:

1.PNG

bpatel
Alteryx Alumni (Retired)

after you change the data types to strings use this PadLeft([month], 2, '0')

Simha
9 - Comet

Hi,

 

You can do something like this:

 

Simha_0-1583164738491.png

 

Regards

Simha

 

 

parria1
8 - Asteroid

THIS GIVES ME A MALFORMED FUNCTION CALL

 

tostring([order_yr] + "-" + padleft(tostring([order_mth_num]),2,"0")

bpatel
Alteryx Alumni (Retired)

you are missing a ")" 

 

tostring([order_yr]) + "-" + padleft(tostring([order_mth_num]),2,"0")

 

that should work

Labels