cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

Swap values in the same row between two columns

Hello,

Is it possible to swap values in two columns for the same row?  For example; Row 10-Column A and Row 10-Column B need to have the values swapped.

 

NOTE:  All other values in these columns are correct.  For some reason, these two particular values must have been entered incorrectly in the source data.

 

Any help would be appreciated

1 ACCEPTED SOLUTION
Community Champion
Community Champion

Hi @Bingo

 

First Add an Index Column from the Query Editor to identify row number

 

then you can use this Custom Column to get revised Column Values with swapped rows

 

if [Index]=10 then [Col B] else [Col A])

swap.png

 

Regards,
Zubair


View solution in original post

3 REPLIES 3
Community Champion
Community Champion

Hi @Bingo

 

First Add an Index Column from the Query Editor to identify row number

 

then you can use this Custom Column to get revised Column Values with swapped rows

 

if [Index]=10 then [Col B] else [Col A])

swap.png

 

Regards,
Zubair


View solution in original post

@Bingo

 

Please see Query Editor in attached file

 

 

Regards,
Zubair


Thanks Zubair.  That worked very nicely.  I actually had the ID already inserted but wasn't connecting the dots enough to think of a conditional column like that.  For the record, I actually had a couple of incorrect values to change.  I also added a second column to complete the swap.  I've included some notes in case somSwapping values.JPGeone has a similar problem in the future.

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors