Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Leading zeros for alphanumeric column

Hi,

 

I have a column with alphanumeric value. Some of the values are 5 digits, I would like to create a new column and add leading zero to make it all 6 digits.

 

I am using below but its giving me error as the column contains alphanumeric value and is in text data type 

 

= Table.AddColumn(#"Previous Step", "Leading 0s", each Number.ToText([C_ColumnAlphaNumeric], Text.Repeat("0",6)))

 

How can I add leading zeros column?

 

Thanks,

 

Daven

  • Anonymous 

    is this what you want?

    if Text.Length([Column1])=6 then [Column1] else "0"&[Column1]

3 Replies

  • Anonymous 

    is this what you want?

    if Text.Length([Column1])=6 then [Column1] else "0"&[Column1]