谷歌表格中有两个标签的查询功能

时间:2021-07-21 14:34:10

标签: google-sheets

我在两张纸(分别为 Cat1、Cat2)中有一个更大版本的下表

screengrab 我想得到如下输出:

<头>
城市 类别
波士顿
波士顿 啤酒
波士顿 汉堡

当矩阵 = 就绪时,它会向我显示城市和就绪的类别。我以前从未使用过查询,我尝试过的也没有奏效,但这似乎是适合这项工作的工具。感谢任何帮助,TIA!

1 个答案:

答案 0 :(得分:1)

在新工作表的单元格 A1 中尝试此操作(删除下面的所有内容):

=arrayformula({"City","Category";query(split(flatten({'Cat1'!A2:A&char(9999)&if('Cat1'!B2:D="Ready",'Cat1'!B1:D1,);'Cat2'!A2:A&char(9999)&if('Cat2'!B2:D="Ready",'Cat2'!B1:D1,)}),char(9999)),"where Col2 is not null order by Col1,Col2",0)})

enter image description here

有 12 列:

=arrayformula({"City","Category";query(split(flatten({'Cat1'!A2:A&char(9999)&if('Cat1'!B2:M="Ready",'Cat1'!B1:M1,);'Cat2'!A2:A&char(9999)&if('Cat2'!B2:M="Ready",'Cat2'!B1:M1,)}),char(9999)),"where Col2 is not null order by Col1,Col2",0)})

enter image description here

'Cat1' sheet

'Cat2' sheet