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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Hamdan1234
Helper III
Helper III

M and B

I have the Balance Sheet data where it shows the sales  and % in this format 1.36M , 2.4B and 1.2% now I want the Power query to convert it in 1360000,2400000000 and % should remain the same. Is their any way ? I have tried doing it with Replace value but did not work. Is there a way to convert it with power query not with DAX?

Thanks

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Hamdan1234 ,

 

Two menthods, please check:

 

#1. Replace value on current column.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMtQzNvNVitWJVjLSM3ECMwz1jFSVYmMB", BinaryEncoding.Base64),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Sales = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Sales", type text}}),
  Custom1 = Table.ReplaceValue(
    #"Changed Type",
    each [Sales],
    each
      if Text.EndsWith([Sales], "M") then
        Text.From(Number.From(Text.Replace([Sales], "M", "")) * 1000000)
      else if Text.EndsWith([Sales], "B") then
        Text.From(Number.From(Text.Replace([Sales], "B", "")) * 1000000000)
      else
        [Sales],
    Replacer.ReplaceText,
    {"Sales"}
  )
in
  Custom1

custom1.PNG

 

#2. Create a new column.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMtQzNvNVitWJVjLSM3ECMwz1jFSVYmMB", BinaryEncoding.Base64),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Sales = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Sales", type text}}),
  #"Added Custom" = Table.AddColumn(
    #"Changed Type",
    "Custom",
    each
      if Text.EndsWith([Sales], "M") then
        Number.From(Text.Replace([Sales], "M", "")) * 1000000
      else if Text.EndsWith([Sales], "B") then
        Number.From(Text.Replace([Sales], "B", "")) * 1000000000
      else
        [Sales]
  )
in
  #"Added Custom"

custom.PNG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Hamdan1234 ,

 

Two menthods, please check:

 

#1. Replace value on current column.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMtQzNvNVitWJVjLSM3ECMwz1jFSVYmMB", BinaryEncoding.Base64),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Sales = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Sales", type text}}),
  Custom1 = Table.ReplaceValue(
    #"Changed Type",
    each [Sales],
    each
      if Text.EndsWith([Sales], "M") then
        Text.From(Number.From(Text.Replace([Sales], "M", "")) * 1000000)
      else if Text.EndsWith([Sales], "B") then
        Text.From(Number.From(Text.Replace([Sales], "B", "")) * 1000000000)
      else
        [Sales],
    Replacer.ReplaceText,
    {"Sales"}
  )
in
  Custom1

custom1.PNG

 

#2. Create a new column.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMtQzNvNVitWJVjLSM3ECMwz1jFSVYmMB", BinaryEncoding.Base64),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Sales = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Sales", type text}}),
  #"Added Custom" = Table.AddColumn(
    #"Changed Type",
    "Custom",
    each
      if Text.EndsWith([Sales], "M") then
        Number.From(Text.Replace([Sales], "M", "")) * 1000000
      else if Text.EndsWith([Sales], "B") then
        Number.From(Text.Replace([Sales], "B", "")) * 1000000000
      else
        [Sales]
  )
in
  #"Added Custom"

custom.PNG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AlexisOlson
Super User
Super User

You can control the display format in the visual Format pane.

https://powerbidocs.com/2020/09/26/custom-display-units-in-power-bi/

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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