Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Last active November 18, 2019 20:55
Show Gist options
  • Save ImkeF/b990a56ee5f2eadddb145324a9224a84 to your computer and use it in GitHub Desktop.
Save ImkeF/b990a56ee5f2eadddb145324a9224a84 to your computer and use it in GitHub Desktop.
M functions
let func =
(TableWithCode as table, CodeColumnName as text) =>
let
Source= TableWithCode,
EvaluateFunction = Table.AddColumn(Source, "Value", each Expression.Evaluate(Record.Field(_, CodeColumnName), #shared)),
Cleanup = Table.RemoveColumns(EvaluateFunction,{CodeColumnName}),
ToRecord = Record.FromTable(Cleanup)
in
ToRecord
, documentation = [
Documentation.Name = " fnRecord.ToFunctionRecord
", Documentation.Description = " Converts a table with function code to a record where the function is active
", Documentation.Category = " Table
", Documentation.Author = " Imke Feldmann: www.TheBIccountant.com
", Documentation.Examples = {[Description = "
" , Code = " Check this blogpost explaining how it works: http://wp.me/p6lgsG-Gx
", Result = "
"]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment