Forum Discussion

sfung's avatar
sfung
New Member
6 years ago
Solved

Manually moving rows in a table

Hi, I'm reporting data in a table format. I have sorted rows in order by columns but need to manually move one row..   Is there a way to do this?   Thanks
  • Anonymous's avatar
    Anonymous
    6 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
        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