Skip to main content
100%

Swapping the list elements in positions _from and _to. Power Query implementation

✓ Published0🌍 Public
HHugoberry
Last edited Mar 1, 2017
Created on Mar 1, 2017

This example demonstrates a reusable Power Query function that swaps two elements in a list by their zero-based positions. The visualization highlights the function’s logic: it first normalizes the _from and _to indices by sorting them, then reconstructs the list using List.Range, concatenating the segments before, between, and after the swapped elements. The function returns the original list unchanged if the indices are equal. The implementation relies solely on Power Query’s standard library functions, such as List.Range and the concatenation operator, with no external libraries. The gist shows a compact, purely functional approach to list manipulation, making the data transformation explicit and testable.

AI-generated description

Similar vizzes