How to edit M-function documentation metadata

After the great announcement yesterday that we will be able to ship custom functions within the shared environment, I’m expecting a lot of people starting to write awesome custom functions for M. Hopefully they will all have nice function descriptions/metadata shipped with them, that makes it as easy as possible for users to apply them correctly:

Please read here how to do that.

What’s also cool: You can add your own records, like Author, Source or Link… . Only thing I haven’t found out yet: If/how to make these fields appear in the dialogue when called. Anyone an idea here?

= let
   func = () as number => 123,
   documentation = [
    Documentation.Name = "MyFunction",
    Documentation.Description = "Returns a shiny new number.",
    Documentation.LongDescription = "Returns a magical, shiny, brand-new number.",
    Documentation.WhoAskedTheRightQuestion = "www.TheBIccountant.com",
    Documentation.Category = "Number",
    Documentation.Examples = {[Description = "The first example.", Code = "MyFunction()", Result = "123"]}
    ]
  in
   Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))

If you copy this into the advanced editor, you’ll see that not only my new field “WhoAskedTheRightQuestion” but also the Description doesn’t show as well. I think it would be very helpful, if that could be adjusted.

Edit 2017-May-18: You’ll find the new documentation about this feature here. Some nice additional features like allowed values and sample values for function parameters. But no possibility to include own fields in the display.

Edit 2018-Jan-17: There’s another very nice and detailed documentation from Lars Schreiber here.

Enjoy & stay queryious 🙂

Comments (9) Write a comment

  1. changed returned number to the correct one and everything looks ok for me:

    let
    abc = let
    func = () as number => 42,
    documentation = [
    Documentation.Name = “MyFunction”,
    Documentation.Description = “Returns a shiny new number.”,
    Documentation.LongDescription = “Returns a magical, shiny, brand-new number.”,
    Documentation.WhoAskedTheRightQuestion = “www.TheBIccountant.com”,
    Documentation.Category = “Number”,
    Documentation.Examples = {[Description = “The first example.”, Code = “MyFunction()”, Result = “42”]}
    ]
    in
    Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)),

    efg = Value.Metadata(Value.Type(abc))
    in
    efg

    Reply

    • Hi Maxim,
      thx for the code! Just recognized that I had a typo in there. It’s not the LongDescription that doesn’t show up, but the Description (“Returns a shiny new number.”) that isn’t shown in the dialoge.

      Your code makes that visible: It returns a record that includes all the fields:
      RecordReturningAllFields

      But if you click with your mouse on step “abc” you will see the dialogue like in the post above where the 2 red fields are missing.
      Thank you!!

      Reply

  2. Pingback: #Excel Super Links #42 – shared by David Hager | Excel For You

  3. Pingback: #Excel Super Links #82 – shared by David Hager | Excel For You

  4. Thanks for the Nice post! It’s much more informative for me than original documentation!

    BTW I found that in your post quotes are in format that Power Query don’t understand. So I needed to replace them. Just in case if you didn’t know…

    Reply

  5. Pingback: Writing documentation for custom M-functions, Part3 | THE SELF-SERVICE-BI BLOG

Leave a Reply