cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Power Query/M Formatter

Hi Group,

 

we developed a formatter for M/PowerQuery a couple of weeks ago. You find it here:

https://powerqueryformatter.com

 

You can format M-code online or use our API - as we use the API for our (german) blog https://durchblick-durch-daten.de (formerly https://powerpivotinsights.de). 

Please give it a try - and if you have any suggestions or if you find any problems, do not hesitate to send a bug report (link is on the website).

Thanks,

Holger

5 REPLIES 5
Highlighted
Super User IV
Super User IV

Re: Power Query/M Formatter

Very nice, I did something simple but it worked great! Turned this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc3BCQAhDETRXnIWSWLGaC1i/21sFPawkJ3rY/hrkVAhqfwd7bIIIWopWVBPpZ1TKvob6keUU+OK+3NXQxvgyYC+ZremMgQT1hzeZ9h+AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [z = _t, #"GAMMA (Excel)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"z", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"GAMMA (Excel)"})
in
    #"Removed Columns"

Into:

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "dc3BCQAhDETRXnIWSWLGaC1i/21sFPawkJ3rY/hrkVAhqfwd7bIIIWopWVBPpZ1TKvob6keUU+OK+3NXQxvgyYC+ZremMgQT1hzeZ9h+AA==", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type text) meta [Serialized.Text = true])
    in
      type table[z = _t, #"GAMMA (Excel)" = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"z", type number}}),
  #"Removed Columns" = Table.RemoveColumns(#"Changed Type", {"GAMMA (Excel)"})
in
  #"Removed Columns"

Much more readable and it had colors as well but those didn't paste over! Not your fault! 🙂


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Super User IV
Super User IV

Re: Power Query/M Formatter

So cool, has a copy HTML feature so you CAN get the colors to paste over!! 🙂
 
let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "dc3BCQAhDETRXnIWSWLGaC1i/21sFPawkJ3rY/hrkVAhqfwd7bIIIWopWVBPpZ1TKvob6keUU+OK+3NXQxvgyYC+ZremMgQT1hzeZ9h+AA==", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type text) meta [Serialized.Text = true])
    in
      type table[z = _t, #"GAMMA (Excel)" = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"z", type number}}),
  #"Removed Columns" = Table.RemoveColumns(#"Changed Type", {"GAMMA (Excel)"})
in
  #"Removed Columns"

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Super User IV
Super User IV

Re: Power Query/M Formatter

Just added this to my favorites bar!

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Helper I
Helper I

Re: Power Query/M Formatter

Hi Greg,

 

what do you mean with "colors didn't paste over"? If you cut/paste it to something like "word", this is working. If you copy"html" you can use it on your webstie (with colors). Ok, using the powerquery - we do not have a change because this is text only 🙂

 

Holger

Highlighted
Super User IV
Super User IV

Re: Power Query/M Formatter

Yep @ppvinsights I figured it out, HTML copy, super cool

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Helpful resources

Announcements
June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021