Forum Discussion
How to swap some values between two columns in power query using either GUI elements or M code?
How to swap some values between two columns in power query using either GUI elements or M code?
Hi Aasozab, I recommend you to create new pair of columns with extracted values:
[Extracted Date]
if (try Date.From([Column1]) otherwise false) is date then [Column1] else [Column2][Extracted Text]
if [Column1] = [Extracted Date] then [Column2] else [Column1]
10 Replies
- dufoq3Community Champion
Hi, I dind´t provide the code with sample data, but you can create it either in power query vie Enger Data button or in excel and then import to power query.
The purpose was to show sou the way how to achieve expected result. You can use codes above by adding them separately as custom column. Just replace [Column1] with [DOJ] and [Column2] with [Designation]. Don't forget to set column name for first code: "Extracted Date".
- AlienSxSuper User
Table.ReplaceValue( your_table, each [DOJ], each [Designation], (v, o, n) => if Value.Is(n, Text.Type) then v else if Value.Is(v, Text.Type) then n else o, {"DOJ", "Designation"} ) - AasozabRegular Visitor
Thank you for your reply. Would you plz tell me how can i download sample data you provided in the solution?