Add leading zeros if length = 4

syazwaan
syazwaan New Altair Community Member
edited November 2024 in Community Q&A
I have a dataset something like this:

I want to add leading 0 if the length of data in column_1 is 4 and return in a new column. So that all data in the new column will be the length of 5.

Expected output:

Thank you.

Best Answer

  • BalazsBaranyRM
    BalazsBaranyRM New Altair Community Member
    Answer ✓
    Hi!

    If the data are numeric, you can use Format Numbers with a pattern of 00000. This will convert the numbers to a nominal column with the specified format that includes the leading zero if necessary. This would also work for smaller numbers.

    Regards,
    Balázs

Answers

  • Caperez
    Caperez Altair Community Member
    Hi @syazwaan
    A possible solution is work with a nominal data and logic if rule. 
    please find attached a simple sample. 
    Best
  • BalazsBaranyRM
    BalazsBaranyRM New Altair Community Member
    Answer ✓
    Hi!

    If the data are numeric, you can use Format Numbers with a pattern of 00000. This will convert the numbers to a nominal column with the specified format that includes the leading zero if necessary. This would also work for smaller numbers.

    Regards,
    Balázs

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.