IMT*_*Man 3 google-sheets array-formulas gs-vlookup google-sheets-query google-sheets-formula
我试图找到一个公式,将表分组到列上,并将另一列中所有行的值连接起来。
例如,如果这是我的表:
| name | value |
|-------|---------|
| one | alpha |
| two | bravo |
| three | charlie |
| one | delta |
| two | echo |
| four | foxtrot |
| two | golf |
| three | hotel |
| four | india |
Run Code Online (Sandbox Code Playgroud)
这就是我想要的公式输出:
| one | alpha, delta |
| two | bravo, echo, golf |
| three | charlie, hotel |
| four | foxtrot, india |
Run Code Online (Sandbox Code Playgroud)
我希望我能分享一些让我接近的公式,但我找不到任何东西。我想也许这个公式,但是,正如您从样本表中看到的,它不起作用。
=ARRAYFORMULA(JOIN(", ", TRANSPOSE(FILTER(B2:B, A2:A = {UNIQUE(A2:A)}))))
Run Code Online (Sandbox Code Playgroud)
我的想法是,获取列中唯一的值列表name,然后用于arrayformula获取列中的值列表value,其中该name列等于唯一列表中的每个值。:/
尝试:
\n\n=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(\n QUERY(QUERY({A2:A&"\xe2\x99\xa6", B2:B&","}, \n "select max(Col2) \n where Col1 !=\'\' \n group by Col2 \n pivot Col1"),,999^99)), "\xe2\x99\xa6")), ",$", ))\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n或者:
\n\n=ARRAYFORMULA(IFNA(VLOOKUP(UNIQUE(A2:A), \n REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(\n QUERY(QUERY({A2:A&"\xe2\x99\xa6", B2:B&","}, \n "select max(Col2) \n where Col1 !=\'\' \n group by Col2 \n pivot Col1"),,999^99)), "\xe2\x99\xa6")), ",$", ), {1, 2}, 0)))\nRun Code Online (Sandbox Code Playgroud)\n\n\n