从同一单元格中的多个工作表返回ArrayFormula

时间:2017-11-13 00:47:16

标签: google-sheets spreadsheet worksheet-function array-formulas

我有两张带有不同漫威角色的Google表格(A栏)及其对应的家庭宇宙(C栏)。

Sheet 1中

| Heroes            | Count         | Universe           |
|:------------------|--------------:|:------------------:|
| Spider Ham        | 365           | Earth-8311         |
| Iron Man          | 467           | Earth-616          |
| Hulk Bunny        | 24            | Earth-8311         |

Sheet 2中

| Heroes            | Count         | Universe           |
|:------------------|--------------:|:------------------:|
| Spider Ham        | 234           | Earth-8311         |
| Iron Man          | 998           | Earth-616          |
| May Porker        | 11            | Earth-8311         |

Sheet3 中,每行=ArrayFormula(TEXTJOIN(", ";1;REPT(Sheet1!A:A;1*(Sheet1!C:C=A$2))))中的此公式(放在B列中)抓取Sheet1中的数据并以这样的方式返回:

| Universe         | Heroes                              |
|:-----------------|------------------------------------:|
| Earth-8311       | Spider Ham, Hulk Bunny              |
| Earth-616        | Iron Man                            |

哪个好。但我也想在公式中合并Sheet2中的数据 - 所以Sheet3看起来像这样(没有重复):

| Universe         | Heroes                              |
|:-----------------|------------------------------------:|
| Earth-8311       | Spider Ham, Hulk Bunny, May Porker  |
| Earth-616        | Iron Man                            |

我想修改ArrayFormula以在Sheet1和Sheet2中搜索 - 这是否可以在单个Spreadsheet-formula中进行?

尝试=ArrayFormula(TEXTJOIN(", ";1;REPT(Sheet1:Sheet2!A:A;1*(Sheet1Sheet2!C:C=A$2)))),但它只返回#NAME?

1 个答案:

答案 0 :(得分:2)

请尝试:

=ArrayFormula(TEXTJOIN(", ",1,UNIQUE(filter({Sheet1!A:A;Sheet2!A:A},{Sheet1!C:C;Sheet2!C:C}=A2))))

在Google表格中使用arrays {},以及filter公式。 Unique是摆脱重复的。