Skip to content

Instantly share code, notes, and snippets.

@Hugoberry
Forked from ImkeF/List.SelectPositions.pq
Last active January 20, 2020 16:08
Show Gist options
  • Save Hugoberry/a25bf43fbc2ada9a1cc29f874f509134 to your computer and use it in GitHub Desktop.
Save Hugoberry/a25bf43fbc2ada9a1cc29f874f509134 to your computer and use it in GitHub Desktop.
let func =
(SelectionList as list, ListOfPositions as list, optional StartWithOne as number) =>
let
selectionList = List.Buffer(SelectionList),
listOfPositions = List.Buffer(ListOfPositions),
StartPosition = if StartWithOne = 1 then -1 else 0,
Result = List.Transform(ListOfPositions, each SelectionList{_ + StartPosition}?)
in
Result
, documentation = [
Documentation.Name = " List.SelectPositions
", Documentation.Description = " Selects all items from <code>SelectionList</code> that are on positions in <code>ListOfPositions</code>.
" , Documentation.LongDescription = " Selects all items from <code>SelectionList</code> that are on positions in <code>ListOfPositions</code>. For the behaviour of the optional parameters see: https://wp.me/p6lgsG-N8 .
", Documentation.Category = " List Selection
", Documentation.Source = " https://wp.me/p6lgsG-N8 .
", Documentation.Author = " Imke Feldmann: www.TheBIccountant.com .
", Documentation.Examples = {[Description = " For details see: https://wp.me/p6lgsG-N8 .
" , Code = " List.SelectPositions({1..5}, {0, 3, 4})
", Result = " {1,4,5}
"]}]
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