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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
nisha_deepak
Helper III
Helper III

Comma formatting

I have a field named Flood Details which is text type contains mix  of numbers plus text value like i show below.

Capture.PNG

 

i want to format number values with comma separated like this example below;

if value is

2,50,000   = 250,000(change to like this)

1,00,000   = 100,000(change to like this)

1000000    = 1,000,000(change to like this).

Above column column conatin mix of type (number + text).I can't format to whole number .

How can i do this ?

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @nisha_deepak 

Please see this sample PBIX file for this M Code to do what you want.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVMTAwUIrVATJ1TA3gHEMgC8ExAAMw2y+/RME5vyy1KDUFzIdoVVXIzcxTMETSo6sUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [all = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each try Number.ToText(Number.From([all]),"N") otherwise [all]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each try if Text.Contains([Custom],".00") then Text.Start([Custom],Text.Length([Custom])-3) else [Custom] otherwise ""),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
    #"Removed Columns"

 

 

num-format.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
PhilipTreacy
Super User
Super User

Hi @nisha_deepak 

Please see this sample PBIX file for this M Code to do what you want.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVMTAwUIrVATJ1TA3gHEMgC8ExAAMw2y+/RME5vyy1KDUFzIdoVVXIzcxTMETSo6sUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [all = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each try Number.ToText(Number.From([all]),"N") otherwise [all]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each try if Text.Contains([Custom],".00") then Text.Start([Custom],Text.Length([Custom])-3) else [Custom] otherwise ""),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
    #"Removed Columns"

 

 

num-format.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


thanks....this help me to solve my issue

amitchandak
Super User
Super User

@nisha_deepak ,

Create a column likein power query

= " " & [flood details] 

split by last occurance of space " "

and then remove/replace comma

 

Split By Delimiter.png

 

Replace : https://www.howtoexcel.org/power-query/bulk-replace-values/

I need to change numbers only to format with commas...

example value from flood details like 

2,50,000   = 250,000(change to like this)

1,00,000   = 100,000(change to like this)

1000000    = 1,000,000(change to like this).

 

I want to put the value like 2% min 100,000 this as itself in column.Only this type of values to be changed from 2,50,000 to 250,000. Is it possible?plse help...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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