英文:
How compare 4 columns
问题
我在Excel中使用表格。以下是工作表的示例:
首先,我必须比较列A中的重复值,并获得列A、B、C和D的表格。然后,我必须同时比较列B、C和D。
之后,我必须创建一个新列,如果它们都匹配则将1放入该列,否则放入0。
如何在Excel中使用函数来实现这一点?
首先,您需要使用Excel的功能来比较列A中的重复值,然后创建一个新表格包含列A、B、C和D。您可以使用以下公式来获取列A中的重复值:
=IF(COUNTIF($A$2:$A$12,A2)>1,A2,"")
将此公式放入新的列E,然后拖动以填充整个列。这将为您提供列E,其中仅包含列A中的重复值。
接下来,您需要使用函数来比较列B、C和D,并根据匹配情况创建新的列F。您可以使用以下公式来实现:
=IF(AND(B2=B3, C2=C3, D2=D3), 1, 0)
将此公式放入新的列F,并将其拖动以填充整个列。这将为您提供列F,其中包含1表示匹配,0表示不匹配。
最终结果将是您所期望的:
E F
al 0
ff 1
其中0表示有不匹配的行,1表示相匹配的行。
希望这可以帮助您完成您的任务。如有其他问题,请随时告诉我。
英文:
I'm working with a table in Excel. Here is an example of the Sheet:
A B C D
al id id id
df id desc desc
df id id desc
df id id id
ff desc id desc
ff desc id desc
al id id id
al id id desc
mn desc desc desc
mn desc desc desc
ff desc id desc
First of all, I have to compare the column A with duplicate values and you will get a table of columns A B C and D. With that table, I have to compare de columns B C and D at once.
Later, I have to create a new column where I have to put 1 if they all match, 0 otherwise.
How can I do that in Excel with functions??
Here is an example:
First row with values: al id id id. There are to compare with all rows in the column A and save each row that that is matched. In this case:
A B C D
al id id id
al id id desc
So, this is what we get:
A B C D
al id id id
al id id id
al id id desc
Therefore, we have to compare each row in the same column. So, B1=B2, B1=B3, B2=B3. As the last column is not equal, you have to create a new column with the value 0 because there is not a complete coincidences.
Another examples, for: ff desc id desc. There are to compare with all rows in the column A and save each row that that is matched. In this case:
A B C D
ff desc id desc
ff desc id desc
So, this is what we get:
A B C D
ff desc id desc
ff desc id desc
ff desc id desc
As the columns match, in the new column would have to be 1.
Final result with the two examples:
E F
al 0
ff 1
where 0 means that there are mismatched rows, 1 for equals.
I hope I have explained well.
Any questions, let me know.
答案1
得分: 2
匹配唯一的列
- 如果你喜欢1和0,请用它们替换"Yes"和"No"。
=LET(d,A2:D12,uc,1,y,"Yes",n,"No",
ud,INDEX(d,,uc),u,UNIQUE(ud),um,XMATCH(ud,u),
us,XMATCH(SEQUENCE(ROWS(u)),um),
ui,INDEX(d,us,SEQUENCE(,COLUMNS(d))),
nc,BYROW(u,
LAMBDA(r,ROWS(UNIQUE(FILTER(d,ud=r)))=1)),
HSTACK(ui,IF(nc,y,n)))
=LET(d,A2:D12,uc,1,y,"Yes",n,"No",
ud,INDEX(d,,uc),u,UNIQUE(ud),
nc,BYROW(u,
LAMBDA(r,ROWS(UNIQUE(FILTER(d,ud=r)))=1)),
HSTACK(u,IF(nc,y,n)))
注意,单元格B12
与上一张截图中的不同。
英文:
Match Unique Columns
Edit
- If you prefer the 1s and 0s, replace the "Yes"-es and "No"-s with them.
=LET(d,A2:D12,uc,1,y,"Yes",n,"No",
ud,INDEX(d,,uc),u,UNIQUE(ud),um,XMATCH(ud,u),
us,XMATCH(SEQUENCE(ROWS(u)),um),
ui,INDEX(d,us,SEQUENCE(,COLUMNS(d))),
nc,BYROW(u,
LAMBDA(r,ROWS(UNIQUE(FILTER(d,ud=r)))=1)),
HSTACK(ui,IF(nc,y,n)))
=LET(d,A2:D12,uc,1,y,"Yes",n,"No",
ud,INDEX(d,,uc),u,UNIQUE(ud),
nc,BYROW(u,
LAMBDA(r,ROWS(UNIQUE(FILTER(d,ud=r)))=1)),
HSTACK(u,IF(nc,y,n)))
- Note that cell
B12
is different than in the previous screenshot.
Initial Post
=LET(d,A2:D12,uc,1,
ud,INDEX(d,,uc),u,UNIQUE(ud),um,XMATCH(ud,u),
us,XMATCH(SEQUENCE(ROWS(u)),um),
ui,INDEX(d,us,SEQUENCE(,COLUMNS(d))),
nc,BYROW(DROP(ui,,1),
LAMBDA(r,--(COLUMNS(UNIQUE(r,1))=1))),
HSTACK(ui,nc))
答案2
得分: 1
公式在 F1
中:
=LET(x,UNIQUE(A1:A11),HSTACK(x,--MAP(x,LAMBDA(y,ROWS(UNIQUE(FILTER(B1:D11,A1:A11=y)))=1))))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论