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
arpost
Advocate V
Advocate V

Is it possible to format numbers using text format strings in Power Query?

Greetings, all. I have a scenario where I need to push some formatting to Power Query but am finding I can't identify how to do that. Here's the situation.

 

I have a range of dollar amounts and am wanting to format those in specific ways. Here's an example in the Band column:

arpost_0-1644874789506.png

Previously, I did this using DAX with some if logic; here's a snippet:

 

Format([Start],IF([Start]>=1000000000,"$#,,,.##B","$#,##0,,M"))

 

Now, I want to achieve the same result in Power Query but can't seem to identify the correct M function to apply these types of text format strings. Anyone have ideas?

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can write a custom column using Text.Format like this:

if [Start] >= 10000000
then Text.Format("$#{0}M to #{1}M", {[Start]/1000000, [End]/1000000})
else "<$10M"

 

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

You can write a custom column using Text.Format like this:

if [Start] >= 10000000
then Text.Format("$#{0}M to #{1}M", {[Start]/1000000, [End]/1000000})
else "<$10M"

 

That works a treat! Thanks. I know with the FORMAT function in DAX there are different codes/format strings (link), is there a list somewhere of which you know for the Text.Format function in M?

Not that I know of.

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.

Top Solution Authors