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 🙂
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
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:
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!!
Pingback: #Excel Super Links #42 – shared by David Hager | Excel For You
Pingback: #Excel Super Links #82 – shared by David Hager | Excel For You
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…
Thanks Maxim 🙂
Do you have an idea how I can change the quotes to straight?
I suppose it’s because of the chosen WordPress theme.
Did you use “code” formatting for code?
Or it might be “preformatted” option.
https://content.screencast.com/media/08feeba8-b361-47cd-b764-489ed02a380e_9d700cb2-87df-433c-8403-c813c6a51c87_static_0_0_2017-12-05_19-35-06.png
Can you make a screenshot the post edit window? If I saw It, I could tell precisely.
Thanks a lot – that did the trick!
Pingback: Writing documentation for custom M-functions, Part3 | THE SELF-SERVICE-BI BLOG