Concating Columns
![prash_](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar5.png)
I havce to concat :"DG0" Field 1 and "P"
in field 1 there is value 0800
I used the method concat("DG0",filed 1,"P)
I'm getting result like DG0800P instead of GD00800 (one 0 is not taking after concat)
What to do in this case?
Best Answer
Answers
-
strval does not work
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,211 Dataiker
Can you please share a screenshot of the error /output to ilustrate what you mean by it doesn't work?
Thanks -
it is not an error it just does not do what you want it to do. the field is already a string.... that is not the issue. when you put the strval it removes the first field completely which is very bizarre.
so.... concat(column1, " ", column2) removes the leading zeros in column1
concat(strval(column1, " ",column2) removes the first column
also the leading zeros are not a set number. some have 3 some have 5 some have no leading zeros
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,211 Dataiker
Can you try:
concat(strval("col_1"), " ", strval("col_2"))
You need strval in front of each column to keep leading zeros.
-
right.... when you do that it removes both columns. the output column is completely blank
-
Figured it out.
I went to add a new step
clicked on Misc
then used concatenate columns.
Why this works instead of using the formulas I do not know. But this method kept the leading zeros in the first column.