We're excited to announce that we're launching the second installment of Dataiku Product Days Register Now

How to add leading zeros in formula recipe while concatenating strings?

PANKAJ
Level 3
Level 3
How to add leading zeros in formula recipe while concatenating strings?

Suppose I'm concatenating two strings(or integers) or maybe a combination of them and placing the resultant value in a new column using a formula inside prepare recipe. (I'm using formula as concat(strval("col_1"),strval("col_2")) and placing the value in a new column "new_col".)

if col_1 & col_2 have values 00 & 0011 respectively it gives 000011.or

if col_1 & col_2 have values S & 0125 respectively it gives S0125.

To standardize the new column, I want 4 digit strings from col_1 & col_2 respectively by placing leading zeros in whichever column requires so that my resultant output will be 00000011 instead of 000011 and 000S0125 instead of S0125.

Any inputs on how can I put those leading zeros? Do I need any changes in that formula?

0 Kudos
1 Reply
CoreyS
Community Manager
Community Manager

Hi @PANKAJ this resource in the Knowledge Base should help: 

How to pad a number with leading zeros

I hope this helps!

Looking for more resources to help you use Dataiku effectively and upskill your knowledge? Check out these great resources: Dataiku Academy | Documentation | Knowledge Base

A reply answered your question? Mark as ‘Accepted Solution’ to help others like you!
A banner prompting to get Dataiku DSS