Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
1 year ago

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 1Column 2
3850
15
23
1250
11

This should be the result.

Column 1Column 2
3850
1515
2323
1250
1111

Thank you

7 Replies

  • 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's avatar
      Syndicate_Admin
      Icon for Administrator rankAdministrator

      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's avatar
        rajendraongole1
        Icon for Super User rankSuper 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.

  • 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.

  • Anonymous's avatar
    Anonymous
    Not 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.

  • Anonymous's avatar
    Anonymous
    Not 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.

  • Anonymous's avatar
    Anonymous
    Not 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.