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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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

Use M, in transform data mode

https://docs.microsoft.com/en-us/powerquery-m/text-format

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

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

Use M, in transform data mode

https://docs.microsoft.com/en-us/powerquery-m/text-format

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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