Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
How to swap some values between two columns in power query using either GUI elements or M code?
Solved! Go to Solution.
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]
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"}
)
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".
Thank you for your reply. Would you plz tell me how can i download sample data you provided in the solution?
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]
Hi @dufoq3 . I got these errors when followed your steps:
Please tell me:
1. whether or not I followed your steps correctly?
2. Why getting this error?
TIA
I have done so.
Check thse steps and plz tell where I have made a mistake. and why i am getting error in last step and plz also tell what would be next steps?
yes it works now. Thank you so much. I was confused by Note at bottom i.e. Note: Check this link to learn how to use my query. and was following these steps: