转置多列中的唯一值

时间:2019-06-26 20:10:17

标签: google-sheets unique google-sheets-formula array-formulas google-sheets-query

我正在尝试在D1:F中生成唯一值,但是我的公式无法正常工作。例如,第1行具有

A       B       C
milk    milk    44

输出应为:

D      E
milk   44

这是我的公式和我的sheet

=ARRAYFORMULA(unique(A1:C))

1 个答案:

答案 0 :(得分:1)

UNIQUE仅在一个维度(行或列)中起作用

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

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

0