Conditional column to use another value in the table

ruthhacche

Board Regular
Joined
Sep 22, 2017
Messages
84
The third item in this table was transferred from the second item. I need a new column or a way of extracting my original code such that:

If TransferID = 0 then use ItemCode Else return the code associated with the TransferID. So on Row 3 use the ItemCode a1002 (which has ID 7291) rather than a1003 but on all other rows just use the item code. This must be so easy for someone.

1592496231831.png
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
1. Create a new query 'From Table' in Powerquery.
2. Create a custom column that uses ItemID if TransferID is null or TransferID if not null.
3. Create a Duplicate Query.
4. Merge Tables as New (thats my preference).
5. Do a Left (Outer) Join between the tables using the TransferID and ItemID.
6. Expand the resulting table retaining just the new ItemCode column.
7. Delete the custom column created in Step 2.

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,223,791
Messages
6,174,603
Members
452,574
Latest member
hang_and_bang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top