0

Padding zeros

Is there a function in Incorta which could you used as LPAD, which pads zeros to the left of string to make the string of a fixed length?

2replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • You can do this with a formula. Here is an example formula using the Date_Time schema. (old school but it works!) It is coded for a fixed width of 7 characters.

    if(
        length(
            concat(
                "0000000",
                string(
                    Date_Time.Date.Month_Number
                )
            )
        ) > 7,
        substring(
            concat(
                "0000000",
                string(
                    Date_Time.Date.Month_Number
                )
            ),
            length(
                concat(
                    "0000000",
                    string(
                        Date_Time.Date.Month_Number
                    )
                )
            ) - 7
        ),
        concat(
            "0000000",
            string(
                Date_Time.Date.Month_Number
            )
        )
    )
    Like
  • Thanks Marc, taking clue from the formula you have posted I did below and it works fine.

     

    if(

        length(

            ITEM_NUMBER

        ) < 9,

        concat(

            repeat(

                '0',

                9 - length(

                   ITEM_NUMBER

                )

            ),

            ITEM_NUMBER

        ),

        ITEM_NUMBER

    )

    Like
Like Follow
  • 3 wk agoLast active
  • 2Replies
  • 18Views
  • 2 Following

Product Announcement

Incorta 4.9 is now Generally Available (GA)!!!