Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IF Statement with Text.Length and Concat

Hi Experts,

 

Below is my table in Power Query

 

I am adding a Custom column using the if statement in Text.length, below is the power query 

 

However, after adding the custom column I got this below error.  I even tried changing the field type into ABC or 123 but still the same error.  

 

Anyone, Please help!!

 

Thank you

  • Hi Anonymous ,

    Adjust to the below:

    if Text.Length([FLT_CLS_T])  =1 then "000"&([FLT_CLS_T]) else if Text.Length([FLT_CLS_T]) =2 then   
    "00"&([FLT_CLS_T]) else if Text.Length([FLT_CLS_T]) =3 then   "0"&([FLT_CLS_T]) else [FLT_CLS_T]

     

    Did I answer your question? Mark my post as a solution!


    Best Regards

    Lucien

2 Replies

  • v-luwang-msft's avatar
    v-luwang-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

    Adjust to the below:

    if Text.Length([FLT_CLS_T])  =1 then "000"&([FLT_CLS_T]) else if Text.Length([FLT_CLS_T]) =2 then   
    "00"&([FLT_CLS_T]) else if Text.Length([FLT_CLS_T]) =3 then   "0"&([FLT_CLS_T]) else [FLT_CLS_T]

     

    Did I answer your question? Mark my post as a solution!


    Best Regards

    Lucien

  • Anonymous , I see come syntax error

    Text.Length([FLT_CLS_T]) 

    You can not text like 00

    text append like

    "00" & [FLT_CLS_T]