Formula to add leading 'zero' to IDs

I have used these formulas individually and they work, but need to combine as an OR statement

=IF(LEN(MSID@row) = 2, "00" + MSID@row, MSID@row)

=IF(LEN(MSID@row) = 3, "0" + MSID@row, MSID@row)

=IF(OR(IF(LEN(MSID@row) = 2, "00" + MSID@row, MSID@row), LEN(MSID@row) = 3, "0" + MSID@row, MSID@row))

But the combined formula gives an Incorrect Argument Set, any ideas.

Best Answer

  • Anjanesh Vaidya
    Anjanesh Vaidya ✭✭✭✭✭
    Answer ✓

    Hi Kevin7859,

    You can try the below formula to combine both the conditions as mentioned.

    =IF(LEN(MSID@row) = 2, "00" + MSID@row, IF(LEN(MSID@row) = 3, "0" + MSID@row, MSID@row))

    I Hope it will work.

    Thank You!

    Anjanesh Vaidya

    Thanks,

    Anjanesh Vaidya

    Smartsheet Development, Ignatiuz Software

    Did this answer help you? Show some love by marking this answer as "Insightful💡" or "Awesome❤️" and "Vote Up⬆️

Answers

  • Anjanesh Vaidya
    Anjanesh Vaidya ✭✭✭✭✭
    Answer ✓

    Hi Kevin7859,

    You can try the below formula to combine both the conditions as mentioned.

    =IF(LEN(MSID@row) = 2, "00" + MSID@row, IF(LEN(MSID@row) = 3, "0" + MSID@row, MSID@row))

    I Hope it will work.

    Thank You!

    Anjanesh Vaidya

    Thanks,

    Anjanesh Vaidya

    Smartsheet Development, Ignatiuz Software

    Did this answer help you? Show some love by marking this answer as "Insightful💡" or "Awesome❤️" and "Vote Up⬆️

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!