首页 > 解决方案 > 如何在Excel中两列的唯一值之间制作1,0映射文件?

问题描述

嗨,我有一张如下表:

Ortho   Path
L20795  ABbiosynthesis
L43787  ABbiosynthesis
L43789  ABbiosynthesis
L20795  CDbiosynthesis
L43787  CDbiosynthesis
L20632  CDbiosynthesis
L43789  CDbiosynthesis
L20074  XYZpentaABC
L20232  XYZpentaABC
L20508  XYZpentaABC
L20626  XYZpentaABC
L20632  XYZpentaABC
L21692  XYZpentaABC
L21715  XYZpentaABC
L21782  XYZpentaABC
L21825  XYZpentaABC
L25605  XYZpentaABC
L27823  XYZpentaABC
L43767  XYZpentaABC
L45016  XYZpentaABC
L43821  ABCDEFbiosynthesis
L20632  ABCDEFbiosynthesis
L20019  MNOPbiosynthesis
L20059  MNOPbiosynthesis
L20065  MNOPbiosynthesis
L20208  MNOPbiosynthesis
L20209  MNOPbiosynthesis
L20647  MNOPbiosynthesis
L21716  MNOPbiosynthesis
L22371  MNOPbiosynthesis
L22372  MNOPbiosynthesis
L27535  MNOPbiosynthesis
L41610  MNOPbiosynthesis
L46363  MNOPbiosynthesis
L48474  MNOPbiosynthesis

我想在表的第一列和第二列的唯一元素之间进行 0,1 映射。第二列的唯一值将是输出文件中的列名,第一列中的唯一名称将是行名。如果第一列中的唯一值(例如 L48474 和 MNOPbiosynthesis)与第二列中的一个唯一值相关联,则它们的对应值为 1,如果没有关联(L20232 和 MNOPbiosynthesis),则它们的对应值为0. 我期待如下输出:

    ABbiosynthesis  CDbiosynthesis  XYZpentaABC ABCDEFbiosynthesis  MNOPbiosynthesis
L20795  1   1   0   0   1
L43787  1   1   0   0   0
L43789  1   1   0   1   0
L20795  1   1   0   0   0
L43787  1   1   0   0   1
L20632  0   1   1   1   0
L43789  1   1   0   0   0
L20074  0   0   1   0   0
L20232  0   0   1   0   1

谁能告诉我该怎么做?

非常感谢

标签: excel

解决方案


正如@SolarMike 提到的,使用MATCH函数:

=IFERROR((MATCH($D2 & "-" & E$1,$A:$A & "-" & $B:$B,0))^0,0)

在此处输入图像描述


推荐阅读