Forum Discussion

darylmc's avatar
darylmc
Frequent Visitor
6 years ago
Solved

Excel TEXT function - equivalent in DAX

Hi All,

 

I'm looking to replicate =TEXT(A2,"0000") in DAX in order to make sure a string column has at least 4 characters. What is the function to achieve this?

 

Thanks in advance

4 Replies

  • Hi darylmc,

    In DAX:
    FORMAT(TABLE[COLUMN], "0000")

    In query editor:
    Text.PadStart (column, 4, 0)
  • Anonymous's avatar
    Anonymous
    Not applicable
    We have len function to check the length of string.
    New column=if(len(table[oldcolumn])<4,blank(),table[oldcolumn])

    Or you can do this in power query as well

    = if Text.Length([Projekt_ID]) <4 then "" else [project_id]
  • Anonymous's avatar
    Anonymous
    Not applicable
    Use the FORMAT function.

    Best
    D