Skip to content

Instantly share code, notes, and snippets.

@Hugoberry
Created March 1, 2017 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hugoberry/96b0d306ead6df9714d282afe8fb5308 to your computer and use it in GitHub Desktop.
Save Hugoberry/96b0d306ead6df9714d282afe8fb5308 to your computer and use it in GitHub Desktop.
Swapping the list elements in positions _from and _to. Power Query implementation
List.Swap = (_,_from as number ,_to as number) =>
let
from = List.Min({_from,_to}),
to = List.Max({_from,_to})
in if from=to then _ else
List.Range(_,0,from)
&{_{to}}
&List.Range(_,from+1,to-from-1)
&{_{from}}
&List.Range(_,to+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment