Forum Discussion

Spotto's avatar
Spotto
Helper IV
4 years ago
Solved

Text.Length Concat help

HI, 

I HAVE A TABLE with text codes and I needed to add zero (0) at the beginning of codes that have less than 10 characters as in the example below.
I thought of using text.legth in the power query with IF but I couldn't, I appreciate the help.

In the final result I need to create a text code again

 

 

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Spotto ,

    You can use Dax:

    Here are the steps you can follow:

    1. Create calculated column.

    After =
    IF(
        LEN('Table'[Before])<10,0&""&'Table'[Before],'Table'[Before])

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

2 Replies

  • Spotto , Try like this in power query

     

    if Text.Length([Column]) <10 then "0" & [Column] else [Column]

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Spotto ,

    You can use Dax:

    Here are the steps you can follow:

    1. Create calculated column.

    After =
    IF(
        LEN('Table'[Before])<10,0&""&'Table'[Before],'Table'[Before])

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly