excel-formulaformulabyte-order-mark

Excel Formula Assigning Parent Part Number to a Child


I am looking for someone to help me out with a code that once worked but now doesn't and I can't figure out what went wrong. Here is a link to the work sheet: https://1drv.ms/x/s!Au53oWRKuRfD9kanfyQ62uW30r1V

In worksheet 1 (Engineering Release) we will this out and it populates sheet 2 (BOMUploadRelease). In sheet 2 the parent column should populate the parent part number from sheet 1 and concatenate the part number based off the dispo on sheet 1 similar to column A on sheet 2. The number of rows should be the same with part data on both sheets 1 and 2 and everything else to be blank below them. All other columns are working perfectly except the Parent column in sheet 2.

Here is the code for the Parent column is sheet 2 as of now:

=LET(PART_ORIG, A2, 
PART, IFERROR(MID(PART_ORIG, 1, FIND(".", PART_ORIG)-1), PART_ORIG),
DISPO, 'Engineering Release'!$K$6:$K$62,
OUTLINE,'Engineering Release'!$A$6:$A$62,
PARTS, 'Engineering Release'!$B$6:$B$62,
PARENT, IF(NOT(ISNUMBER(FIND(".", OUTLINE))), OUTLINE,LEFT(OUTLINE, LEN(OUTLINE)-2)),
IDENTIFY_PARENT, XLOOKUP(PART, PARTS, PARENT, "Error 1", 0),
PARENT_PART, XLOOKUP(IDENTIFY_PARENT, OUTLINE, PARTS, "Error 2", 0),
IDENTIFY_DISO, XLOOKUP(IDENTIFY_PARENT, OUTLINE,DISPO, "Error 3", 0),
TEXT(IF(IDENTIFY_DISO="Repair",CONCATENATE(PARENT_PART,".R"),IF(IDENTIFY_DISO="Reuse", CONCATENATE(PARENT_PART,".U"), IF(IDENTIFY_DISO="Modify", CONCATENATE(PARENT_PART,".M"), IF(IDENTIFY_DISO="Ref.", CONCATENATE(PARENT_PART,".REF"), IF(IDENTIFY_DISO="New",CONCATENATE(PARENT_PART, ".N"), ""))))),"0"))

Sheet 1: Gets filled out and we use the item number (column A) to determine which part number is a parent or child of another, For example in the table below 1 would be the top parent, 1.1 & 1.2 would be a child of 1, and 1.1.1 would be a child of 1.1. Column B we list the actual part number of the part we are working on, Column K we dispo the part Repair, New, Reuse, Modify, and Reference in order to know what we are doing with the part. Sheet 1 would look something like this:

Sheet 1 Column A Item Sheet 1 Column B Part Number Sheet 1 Column K Dispo
1 123-456 New
1.1 234-789 Repair
1.1.1 A-458-461-78A Modify
1.2 B-234-235-146 Reuse

Sheet 2 (BOMUploadRelease): In column A we use the part number from column A on sheet 1 and add a "." and up to 3 letters based off the dispo on sheet 1 for the name of the BOM so in our system we know what is a part number and what is a BOM Router Number. In Column S on sheet 2 we list the parent BOM Name in the row of the child. Sheet 2 should look like something like this based off of sheet 1:

Sheet 2 Column A BOM Name Sheet 2 Column O BOM Level Sheet 2 Column S Parent BOM Name
123-456.N 0
234-789.R 1 123-456.N
A-458-461-78A.M 2 234-789.R
B-234-235-146.U 1 123-456.N

What am I doing wrong?


Solution

  • As commented, this would work with examples shared =IFERROR(XLOOKUP(O2-1,$O$2:$O2,$A$2:$A2,"",,-1),"")

    But if you need to obtain the values from the other sheet, you could use this formula:

    =LET(x, XLOOKUP(TEXTBEFORE(A2,".",-1),
            'Engineering Release'!$B$6:$B$10,
            'Engineering Release'!$A$6:$A$10),
         y, 'Engineering Release'!$K$6:$K$10,
    IFERROR( XLOOKUP(TEXTBEFORE(x,".",-1),
                     TEXT('Engineering Release'!$A$6:$A$10,"@"),
                     'Engineering Release'!$B$6:$B$10
                     &"."
                     &IFS(y="Ref.","REF",                   
                          y="Repair","R",                    
                          y="Reuse","U",                   
                          y="Modify","M",                    
                          y="new","N")),
             ""))
    

    enter image description here

    The challenge was that the values in Engineering Release column A was mix of text and numbers. I have this converted in the formula, so it works with your data, but it's good practice to store all as text in the first place, so we don't need a formula to convert it.