Created
March 20, 2018 06:45
-
-
Save tonmcg/07935da317fdaf9581c9cb7ec4c4292f to your computer and use it in GitHub Desktop.
M Language Data Processing Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
List.RandomSelection = (sourceList as list) as text => | |
let | |
Selection = sourceList{Number.RoundDown(Number.RandomBetween(0, List.Count(sourceList)))} | |
in | |
Selection, | |
DefineDocs = [ | |
Documentation.Name = " List.RandomSelection", | |
Documentation.Description = " Randomly select a value from a list.", | |
Documentation.LongDescription = " Randomly select a value from a list. The sourceList provides a list of values, either numerical or character.", | |
Documentation.Category = " List.Transform", | |
Documentation.Source = " ", | |
Documentation.Author = " Tony McGovern: www.emdata.ai", | |
Documentation.Examples = { | |
[ | |
Description = "Randomly select a value from a list of countries.", | |
Code = " RandomSelection({""Portugal"", ""United Kingdom"", ""Germany"", ""New Zealand"", ""Australia"", ""Belgium"", ""France""}", | |
Result = "Germany" | |
] | |
} | |
] | |
in | |
Value.ReplaceType( | |
List.RandomSelection, | |
Value.ReplaceMetadata( | |
Value.Type(List.RandomSelection), | |
DefineDocs | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment