Forum Discussion
Manually moving rows in a table
- Anonymous6 years ago
waiting foe MS to develop what you nedde, give a try to this function:
let moveRow = (tab,row, posToMove)=> let Pos=Table.PositionOf(tab,row), fromPos=Table.RemoveMatchingRows(tab,{row}), toPos=Table.InsertRows(fromPos,Pos+posToMove,{row}) in toPos in moveRowif you have a table like this and want to move row [col1=22,col2=bb] two position down
you can call the function and get this
if you want to move row [col1=33,col2=cc] two positio up (use a negative relative position)
it is possible using this scheme to add also the management of moving whatever row from pos Pi to position Pf
waiting foe MS to develop what you nedde, give a try to this function:
let
moveRow = (tab,row, posToMove)=>
let
Pos=Table.PositionOf(tab,row),
fromPos=Table.RemoveMatchingRows(tab,{row}),
toPos=Table.InsertRows(fromPos,Pos+posToMove,{row})
in
toPos
in
moveRow
if you have a table like this and want to move row [col1=22,col2=bb] two position down
you can call the function and get this
if you want to move row [col1=33,col2=cc] two positio up (use a negative relative position)
it is possible using this scheme to add also the management of moving whatever row from pos Pi to position Pf
- Anonymous6 years agoNot applicable
or if you like more to play with GUI (and there aren't to many rows):
- transpose you table;
- move you row that now is a column in the desidered position,
- transpose back you table
PS
if you want to keep the original column names you must, always remaining in the GUI environment, transform the headers in the first row and then at the end promote back the first row to headers
- Anonymous4 years agoNot applicable
where do i put the code that defines the 'MoveRow' function? Im wanting to put the code on an appended query