Skip to content

Instantly share code, notes, and snippets.

@PBI-DataVizzle
Created April 24, 2022 13:12
Show Gist options
  • Select an option

  • Save PBI-DataVizzle/49aaedf9b1edcb70ee6b866bae448161 to your computer and use it in GitHub Desktop.

Select an option

Save PBI-DataVizzle/49aaedf9b1edcb70ee6b866bae448161 to your computer and use it in GitHub Desktop.
M-code template for creating functions
let
    // --- Function segment ---
    // Author: Imran Haq (PBI Queryous)
    output = //fnFunctionName
        (input as list) as table =>
    let
        step1 = "PowerQueryFunctionsHere"
    in
        step1
        ,                                                                
    // --- Documentation segment ---
    documentation = [
    Documentation.Name = " fnGetUniques ", 
    Documentation.Description = " Extract column of unique values ", 
    Documentation.LongDescription
      = " Select Table, Select Column and Invoke. Extracts a column of unique values ", 
    Documentation.Category = " Data Extraction ", 
    Documentation.Source = "  https://github.com/PBIQueryous - PBI Queryous - Stay Queryous  ", 
    Documentation.Version = " 1.0 (21/04/2022) ", 
    Documentation.Author = " Imran Haq (Newcastle upon Tyne) ", 
    Documentation.Examples = {[Description = "  ", Code = "  ", Result = "  "]}
  ]
    // --- Output ---
in
    Value.ReplaceType(                                                           
        output,                                                       
        Value.ReplaceMetadata(                                        
            Value.Type(output),                                                   
            documentation                                             
        )
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment