Excel:从一行中查找唯一值并为其创建一列?

学习者57

我不确定我们是否可以在 excel 中做到这一点。我有一个大约 1000 行的电子表格A,如下所示:

Col 1      Col 2  
Fruit1      (Apple, Banana, Grape, Orange)  
Fruit2      (Apple, Orange)  
Fruit3     (Grape, Banana, Orange)  
Fruit4     (Pineapple)  

我想做的事?这:

Col1        Apple Banana Grape Orange Pineapple  
Fruit1      yes   yes    yes   yes    no  
Fruit2      yes   no     no    yes    no  
Fruit3      no    yes    yes   yes    no  
Fruit4      no    no     no    no     yes  

问题:第 2 列有水果名称。首先为每一行查找唯一的水果名称,然后根据找到的唯一值创建一列。此外,如果值重复,请为再次找到该值的相应行添加是/否。所以我需要将值拆分成列,并为每次重复的值设置一个计数器。我必须从电子表格 A 创建电子表格 B。在示例中,Apple、Banana、Grape、Orange 和 Pineapple 成为唯一的列名,如果找到该值,我会检查每一行的 yes 或 no。

我需要这方面的帮助,已经 2 天了,但我无法想出一个 excel 解决方案。Python 解决方案很简单,但我不能使用编程。

非常抱歉,我的格式游戏在 Stackoverflow 上不强。

谢谢!:)

转发埃德

我觉得有一种方法可以用 TXTSPLIT 或 regex 之类的东西来做到这一点,但我只有 2013 年,显然你这样做了,所以这些不是一个选择。

这只是我头脑中的一个思考过程。我首先将第二列复制到您计划放置表格的工作表中。然后我将通过选择您的数据,然后在您的功能区中选择“文本到列”来开始该工作表。

文本到列

然后你应该在这个屏幕上结束

屏幕 1

选择“分隔”单选按钮,然后按Next

屏幕 2

Make sure you select Comma as your delimiter, or whatever matches what is separating your words. You may want to select "Treat consecutive delimiters as one" if you have gaps in you data such as Apple,,Brains, Beaver Tails. Make sure you do not have space selected as a delimiter incase you have multi word data between your delimeters.

Your data should then be split into multiple columns with each word in its own cell.

结果 1

I would then select each individual column then choose the remove duplicates button. I tried doing multiple columns at once but it did not remove duplicates in all columns when I did that.

So select your column(s)

重复 1

Then select remove duplicates from the ribbon

重复 2

I selected continue with selection as I only wanted to deal with one column at a time.

重复 3

I left the "My data has headers" unchecked and hit ok

重复 4

And voila we have a unique list in the column

Duplicates 5

Repeat this for all columns. Then move your columns into one column and repeat the duplicate process. You could have done this step first but it may have been longer columns to deal with moving around. In the end you should wind up with one column of unique words.

Here all the columns are unique within the column but not the table.

Duplicates 6

So the columns get stacked into 1

Duplicates 7

And after running remove duplicates on the single column the following unique list is obtained.

Duplicates 8

Now you can take that data and transpose it to become your column headers and with a minor tweak you can make your table look like:

Results table

So now that we have our table setup, I would use the following formula in B2 of the table and copy down and right. Note the $ to lock the row or column reference.

=IF(ISNUMBER(FIND(B$1,$B12)),"yes","no")
'FIND is case sensitive

Edit

=IF(ISNUMBER(SEARCH(B$1,$B12)),"yes","no")
'SEARCH is NOT case sensitive

In the case of this formula, B$1 is your header row, and $B12 is the first row of column two with data.

Results look like the following based on the date being layed out in B12:b15

POC

Formulaic alternative

place the following in the third column copy right and down as far as needed.

=TRIM(MID(SUBSTITUTE(","&$B2&REPT(",",6),",",REPT(" ",255)),COLUMNS($B2:B2)*255,255))

I personally would copy it over all the way to column z or so first, then down your 10K rows.

Now for the part that will bog your system down. THIS WILL BE A HUGE AMOUNT OF CALCULATIONS FOR EACH CELL THE FORMULA WINDS UP IN. It will be generating the unique list. Use the following in an unused column starting in the second row. convert the range G12:J15 to match B2:Z10000 or whatever range you wound up with. Change $L$11:L11 to empty space above where you want the first unique name to appear. So if you wanted to start your list in AA2 change it to $AA$1:AA1.

=INDIRECT(TEXT(MIN(IF(($G$12:$J$15<>"")*(COUNTIF($L$11:L11,$G$12:$J$15)=0),ROW($G$12:$J$15)*100+COLUMN($G$12:$J$15),7^8)),"R0C00"),)&""

这是一个数组公式或 CSE。这意味着你将需要使用CONTROL+ SHIFT+ENTER完成公式时,不只是ENTER当您在公式栏中的公式周围看到 {} 时,您就会知道您做对了。这些不能手动添加。仅根据需要复制列表。当没有更多唯一条目时,它将生成空白条目,但它仍在执行大量计算。

从那里您可以使用以下公式生成标题行,假设您在 Sheet1 上完成了上述所有生成。在您想要第一个标题的位置使用以下公式并正确复制:

=INDEX(Sheet1!AA:AA,COLUMN(B1))

然后您可以像手动方法的最后一步中使用的公式一样生成是/否表。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Excel-从一列中水平返回一行中的多个匹配值

来自分类Dev

如何从kusto中的列中分离出唯一值并为其创建新行?

来自分类Dev

需要 Excel 公式将重复行值与一列合并为唯一值

来自分类Dev

如何为 sas 中的每一行分组 50 列并为其值创建一个新列?

来自分类Dev

从一列中的唯一值创建 Pandas DataFrame

来自分类Dev

从一行中的一列检索数据

来自分类Dev

Excel-在一个列中查找唯一值,在另一列中查找对应的值

来自分类Dev

查询以从一行的同一列中获取计算值

来自分类Dev

在每一行中查找唯一值

来自分类Dev

如何使用一列查找行并在另一列中返回同一行的值

来自分类Dev

DataFrame:查找指定行并为同一行中的另一列分配数值

来自分类Dev

在同一行的另一列中为您命名的值查找相应的值

来自分类Dev

取一列的唯一值,并将每个值添加到 data.table 中与 `by` 同一行的唯一列中

来自分类Dev

在熊猫中,如何从一列中的唯一值中创建列,然后根据另一列中的值填充它?

来自分类Dev

根据另一列中的唯一值查找一列中的重复项

来自分类Dev

尝试通过在另一列中查找正确的行来从一列中计算值

来自分类Dev

ACCESS / SQL将多行与一列合并为一行并创建多列

来自分类Dev

如何创建基于同一行中另一列的值命名的新列?

来自分类Dev

在 Pandas 中创建一列,计算另一列中唯一值的数量

来自分类Dev

在MySql中查找基于非唯一列的行

来自分类Dev

每个唯一列值限制一行,按最大列值选择

来自分类Dev

MySQL:如何在MyISAM表中查找具有唯一列值的行?

来自分类Dev

在python中查找具有唯一列值的行

来自分类Dev

如何从一列中的不同值采样而仅返回另一列中唯一的记录?

来自分类Dev

提取R数据框中另一列中具有最大值的唯一行

来自分类Dev

如何检查一列的值是否在另一行的另一列中

来自分类Dev

从 R 中的另一列创建列并为其供电

来自分类Dev

查找唯一列

来自分类Dev

查找唯一列

Related 相关文章

  1. 1

    Excel-从一列中水平返回一行中的多个匹配值

  2. 2

    如何从kusto中的列中分离出唯一值并为其创建新行?

  3. 3

    需要 Excel 公式将重复行值与一列合并为唯一值

  4. 4

    如何为 sas 中的每一行分组 50 列并为其值创建一个新列?

  5. 5

    从一列中的唯一值创建 Pandas DataFrame

  6. 6

    从一行中的一列检索数据

  7. 7

    Excel-在一个列中查找唯一值,在另一列中查找对应的值

  8. 8

    查询以从一行的同一列中获取计算值

  9. 9

    在每一行中查找唯一值

  10. 10

    如何使用一列查找行并在另一列中返回同一行的值

  11. 11

    DataFrame:查找指定行并为同一行中的另一列分配数值

  12. 12

    在同一行的另一列中为您命名的值查找相应的值

  13. 13

    取一列的唯一值,并将每个值添加到 data.table 中与 `by` 同一行的唯一列中

  14. 14

    在熊猫中,如何从一列中的唯一值中创建列,然后根据另一列中的值填充它?

  15. 15

    根据另一列中的唯一值查找一列中的重复项

  16. 16

    尝试通过在另一列中查找正确的行来从一列中计算值

  17. 17

    ACCESS / SQL将多行与一列合并为一行并创建多列

  18. 18

    如何创建基于同一行中另一列的值命名的新列?

  19. 19

    在 Pandas 中创建一列,计算另一列中唯一值的数量

  20. 20

    在MySql中查找基于非唯一列的行

  21. 21

    每个唯一列值限制一行,按最大列值选择

  22. 22

    MySQL:如何在MyISAM表中查找具有唯一列值的行?

  23. 23

    在python中查找具有唯一列值的行

  24. 24

    如何从一列中的不同值采样而仅返回另一列中唯一的记录?

  25. 25

    提取R数据框中另一列中具有最大值的唯一行

  26. 26

    如何检查一列的值是否在另一行的另一列中

  27. 27

    从 R 中的另一列创建列并为其供电

  28. 28

    查找唯一列

  29. 29

    查找唯一列

热门标签

归档