Forum Discussion
Compare 2 columns and return value to one column
Hello community
I have the following query, what logic would apply if the values in column 1 are less than column 2, then the value in column 1 would move to column 2
| Column 1 | Column 2 |
| 38 | 50 |
| 15 | |
| 23 | |
| 12 | 50 |
| 11 |
This should be the result.
| Column 1 | Column 2 |
| 38 | 50 |
| 15 | 15 |
| 23 | 23 |
| 12 | 50 |
| 11 | 11 |
Thank you
7 Replies
- rajendraongole1
Super User
Hi Syndicate_Admin - You can create a new column in Power BI and use the below logic
New_Column2 =IF('Table1'[Column 1] < 'Table1'[Column 2] || ISBLANK('Table1'[Column 2]), 'Table1'[Column 1], 'Table1'[Column 2])Hope this helps.
- Syndicate_Admin
Administrator
Thanks for the help, however I wouldn't want to create a new column because I have 50 columns to compare, and it would be cumbersome for me to create 50 more columns, so I needed to replace it in the same column.
- rajendraongole1
Super User
HI Syndicate_Admin - Open Power Query Editor (Transform Data).
Select Column 2 (the one you want to modify).
Click on "Add Column" → "Custom Column" and enter this formula:output using custom column:
Hope this helps.
- rajendraongole1
Super User
Did I answer your question? we can achieve the same in Power query editor. please check and mark my post as a solution if it meets.
- AnonymousNot applicable
Hi Syndicate_Admin,
Thank you for reaching out in Microsoft Community Forum.
Thank you rajendraongole1 for the helpful response.
As suggested by rajendraongole1, I hope this information was helpful. Please let me know if you have any further questions or you'd like to discuss this further. If this answers your question, please "Accept as Solution" and give it a 'Kudos' so others can find it easily.
Please continue using Microsoft community forum.
Regards,
Pavan. - AnonymousNot applicable
Hi Syndicate_Admin,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please "Accept as Solution" and give a 'Kudos' so other members can easily find it.
Thank you,
Pavan. - AnonymousNot applicable
Hi Syndicate_Admin,
I wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.
If the community member's answer your query, please mark it as "Accept as Solution" and select "Yes" if it was helpful.
If you need any further assistance, feel free to reach out.
Please continue using Microsoft community forum.
Thank you,
Pavan.