将父级零件号分配给子级的Excel公式

huangapple go评论87阅读模式
英文:

Excel Formula Assigning Parent Part Number to a Child

问题

我正在寻找帮助我解决一个曾经有效但现在不起作用的代码的人,我无法弄清楚出了什么问题。

在这里是工作表的链接:https://1drv.ms/x/s!Au53oWRKuRfD9kanfyQ62uW30r1V

在工作表1(工程发布)中,我们填写数据,它会填充工作表2(BOMUploadRelease)。在工作表2中,父级列应该根据工作表1中的部件号填充,并根据工作表1上的dispo连接部件号,类似于工作表2上的A列。两个工作表上的零件数据行数应该相同,其他一切都应该留空。除了工作表2中的Parent列,其他列都完美运行。

以下是当前工作表2中Parent列的代码:

=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"))

工作表1:
在工作表1中,我们填写数据并使用项目号(列A)来确定哪个部件号是另一个部件的父级或子级,例如,在下表中,1是顶级父级,1.1和1.2是1的子级,1.1.1是1.1的子级。列B中我们列出我们正在处理的零件的实际部件号,列K中我们根据工作表1上的dispo列出部件的Repair、New、Reuse、Modify和Reference,以了解我们对零件的操作。工作表1可能如下所示:

工作表1 列A 项目 工作表1 列B 部件号 工作表1 列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

工作表2(BOMUploadRelease):
在工作表2的A列中,我们使用工作表1中A列的部件号,并根据工作表1中的dispo添加一个“.”和最多3个字母,用于BOM的名称,这样在我们的系统中,我们知道哪个是部件号,哪个是BOM路由号。工作表2的S列中,我们在子级的行中列出父级BOM名称。工作表2应该根据工作表1如下所示:

工作表2 列A BOM名称 工作表2 列O BOM级别 工作表2 列S 父级BOM名称
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

我做错了什么?

英文:

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?

答案1

得分: 2

如已评论,这将适用于共享的示例
=IFERROR(XLOOKUP(O2-1,$O$2:$O2,$A$2:$A2,"",,-1),"")

但如果您需要从另一个工作表获取值,您可以使用以下公式:

=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")),
         ""))

挑战是Engineering Release列A中的值是文本和数字的混合。我已经在公式中进行了转换,以使其适用于您的数据,但最好的做法是一开始将所有内容存储为文本,这样我们就不需要一个公式来进行转换。

英文:

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")),
         ""))

将父级零件号分配给子级的Excel公式

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.

huangapple
  • 本文由 发表于 2023年6月29日 04:01:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76576358.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定