Concactenating numbers as strings in a formula
I am trying to merge year and month as follows :
Year: 2023Month: 12
Result : '202312'
Year and month are currently numbers.
When I use concat i get '2023.012.0' when I try strval I get "" .
Below is some testing I performed with the year variable. Any advice? Thanks!
Comments
-
LouisDHulst Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Neuron, Registered, Neuron 2023 Posts: 54 Neuron
Hi @Noah ,
test_concat_Strval is returning blank because you are using it incorrectly: you need to put the col name in quotation marks, so it would be concat(strval("Year_Str"), strval("Year_Str")) ⇒ 2023.02023.0.
There's some documentation on this in the Formula wiki.
You would need to cast your Year and Month column to integer to remove the decimal 0. Right now those columns are of type double or float.
concat(round(Year), round(Month)) should work for you. It'll round the Year and Month to integer, then concat those integers.
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,167 Neuron
I think the issue you have is that your Year and Month variables are not integers which is a mistake you should correct as non integer numbers use more storage and months and years are obviously always integer numbers. Irrespective of this I would use a more clear intention formula with the format function.