Created
March 1, 2017 15:11
-
-
Save Hugoberry/96b0d306ead6df9714d282afe8fb5308 to your computer and use it in GitHub Desktop.
Swapping the list elements in positions _from and _to. Power Query implementation
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
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