Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
darylmc
Frequent Visitor

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

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User
MFelix
Super User
Super User

Hi @darylmc,

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

In query editor:
Text.PadStart (column, 4, 0)

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @darylmc,

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

In query editor:
Text.PadStart (column, 4, 0)

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



amitchandak
Super User
Super User

Anonymous
Not applicable

Use the FORMAT function.

Best
D
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]

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.