在数组的同一列下合并具有相同条件的数据。

huangapple go评论80阅读模式
英文:

Merge data under same criteria in a column of array

问题

我需要合并具有相同键的表的列数据。我将第一个表命名为tb。

|   Name1  |  Name2  |
| -------- | ------- |
|     A    |    X    |
|     B    |    Y    |
|     A    |    Y    |
|     B    |    Z    |
          ↓↓↓
|   Name1  |  Name2  |
| -------- | ------- |
|     A    |   X,Y   |
|     B    |   Y,Z   |

我尝试使用FILTER、UNIQUE和TEXTJOIN的组合,但无法得到所需的结果。这个目标是否可实现?

英文:

I need to merge data of a column of a table that under the same key. I named the first table tb.

|   Name1  |  Name2  |
| -------- | ------- |
|     A    |    X    |
|     B    |    Y    |
|     A    |    Y    |
|     B    |    Z    |
          ↓↓↓
|   Name1  |  Name2  |
| -------- | ------- |
|     A    |   X,Y   |
|     B    |   Y,Z   |

I've tried to use the combination of FILTER, UNIQUE and TEXTJOIN but I can't get the wanted result. Is it even achievable?

答案1

得分: 4

你可以使用以下公式:

=LET(n,Table1[Name1],v,Table1[Name2],h,Table1[#Headers],
m,BYROW(UNIQUE(n),LAMBDA(x,TEXTJOIN(", ",TRUE,FILTER(v,n=x)))),
VSTACK(h,HSTACK(UNIQUE(n),m)))

在数组的同一列下合并具有相同条件的数据。

你可以使用这个公式来实现你的需求。

英文:

you can use this formula:

=LET(n,Table1[Name1],v,Table1[Name2],h,Table1[#Headers],
m,BYROW(UNIQUE(n),LAMBDA(x,TEXTJOIN(", ",TRUE,FILTER(v,n=x)))),
VSTACK(h,HSTACK(UNIQUE(n),m)))

在数组的同一列下合并具有相同条件的数据。

huangapple
  • 本文由 发表于 2023年8月8日 20:09:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76859421.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定