Transpose Unique Values from Multiple Columns

拈花ヽ惹草 提交于 2019-12-24 10:49:51

问题


I'm trying to generate unique values in D1:F but my formula is not working. For example, row 1 has

A       B       C
milk    milk    44

the output should be:

D      E
milk   44

here is my formula and my sheet

=ARRAYFORMULA(unique(A1:C))

回答1:


UNIQUE works only in one dimension (row or column)

=QUERY(UNIQUE({A:A;B:B;C:C}), "where Col1 is not null", 0)


=ARRAYFORMULA(SPLIT(REGEXREPLACE(SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE({QUERY(QUERY(
 UNIQUE(SPLIT(TRANSPOSE(SPLIT(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
 IF(LEN(A2:A), "♠"&A2:A&"♦"&B2:D, )),,999^99)),,999^99)), "♠")), "♦")),
 "select Col1, count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),
 "select Col1 offset 1",0),
 IF(QUERY(QUERY(UNIQUE(SPLIT(TRANSPOSE(SPLIT(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
 IF(LEN(A2:A), "♠"&A2:A&"♦"&B2:D, )),,999^99)),,999^99)), "♠")), "♦")),
 "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0), "offset 1",0)<>"", 
 QUERY(QUERY(UNIQUE(SPLIT(TRANSPOSE(SPLIT(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
 IF(LEN(A2:A), "♠"&A2:A&"♦♀"&B2:D&",", )),,999^99)),,999^99)), "♠")), "♦")),
 "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0), "limit 0",1),)})
 ,,999^99))), ", ♀", ", "), ",$", ), "♀"))



来源:https://stackoverflow.com/questions/56780178/transpose-unique-values-from-multiple-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!