Gist a25bf43fbc2ada9a1cc29f874f509134
✓ Published0🌍 Public
HHugoberry
Last edited Jan 25, 2018
Created on Jan 25, 2018
This example shows a Power Query custom function that extracts list items by their numeric positions, returning a new list with only the selected elements. The function `List.SelectPositions` takes a source list and a list of indices, with an optional parameter to shift the starting index from zero-based to one-based numbering. It uses `List.Transform` with a buffer for performance, applying `_{_ + StartPosition}?` to safely handle out-of-range positions by returning null. The implementation relies on the standard Power Query `List` and `Value` APIs, including `Value.ReplaceType` and `Value.ReplaceMetadata` to attach documentation and usage examples.
AI-generated description