Googlesheet查询-合并两组数据
Google sheet query - combining two sets of data
我有两套数据
Data 1 Data 2
A B C D
Tank No Gross Tank No Packed
1 7.00 1 6.09
2 5.00 2 5.21
3 7.50 3 7.03
4 4.00 4 3.33
5 6.00 5 2.00
6 7.00 6 3.11
7 7.00 7 8.11
8 5.50 9 5.19
9 8.00 10 7.92
10 9.00 11 6.53
11 7.50 12 7.70
12 8.00 13 5.02
13 8.00 14 8.21
14 9.00 15 3.00
15 7.00 16 6.66
16 8.00 17 4.00
17 4.00 19 5.22
18 8.50 20 7.41
19 9.50 21 5.85
20 8.00
21 8.00
IN 第二组数据 Tank no 8 and 18 缺失。现在我想要的是这样的结果。
Tank No Gross Packed
1 7.00 6.09
2 5.00 5.21
3 7.50 7.03
4 4.00 3.33
5 6.00 2.00
6 7.00 3.11
7 7.00 8.11
8 5.50
9 8.00 5.19
10 9.00 7.92
11 7.50 6.53
12 8.00 7.70
13 8.00 5.02
14 9.00 8.21
15 7.00 3.00
16 8.00 6.66
17 4.00 4.00
18 8.50
19 9.50 5.22
20 8.00 7.41
21 8.00 5.85
但是当我使用查询时
=Query(Production,"Select A,B,D where A=C",1)
其中 Production 是 A B C 和 D 列的命名范围,我没有得到想要的结果。
结果停在 7 号坦克。
是这样的
Tank No Gross Packed
1 7.00 6.09
2 5.00 5.21
3 7.50 7.03
4 4.00 3.33
5 6.00 2.00
6 7.00 3.11
7 7.00 8.11
如何使用查询或任何其他 sheet 函数获得我想要的结果。
您可以在此处找到包含数据的 sheet:https://docs.google.com/spreadsheets/d/1TQvm1jLktVb3JcMSN5J2oKEbZX9u4iQQ7LQECaPbQAE/edit?usp=sharing
谢谢
复制 A3:B23 到 E3 和 G3 并向下复制以适应:
=iferror(vlookup(E3,C:D,2,0),"")
解决方案:
不是世界上最干净的,但可以解决问题
={
Query({Production},"select Col1,Col2",1),
ArrayFormula(IFERROR(VLOOKUP(QUERY({Production},"select Col1"),
Query({Production},"select Col3,Col4",1),2,0),))
}
与 pnuts 解决方案(最简单的)的区别是
- 此公式仅存在于一个单元格中,并以所需的形式生成报告
- 100% 基于命名范围,因此您可以将它放在任何您想要的地方而不必担心引用
我有两套数据
Data 1 Data 2
A B C D
Tank No Gross Tank No Packed
1 7.00 1 6.09
2 5.00 2 5.21
3 7.50 3 7.03
4 4.00 4 3.33
5 6.00 5 2.00
6 7.00 6 3.11
7 7.00 7 8.11
8 5.50 9 5.19
9 8.00 10 7.92
10 9.00 11 6.53
11 7.50 12 7.70
12 8.00 13 5.02
13 8.00 14 8.21
14 9.00 15 3.00
15 7.00 16 6.66
16 8.00 17 4.00
17 4.00 19 5.22
18 8.50 20 7.41
19 9.50 21 5.85
20 8.00
21 8.00
IN 第二组数据 Tank no 8 and 18 缺失。现在我想要的是这样的结果。
Tank No Gross Packed
1 7.00 6.09
2 5.00 5.21
3 7.50 7.03
4 4.00 3.33
5 6.00 2.00
6 7.00 3.11
7 7.00 8.11
8 5.50
9 8.00 5.19
10 9.00 7.92
11 7.50 6.53
12 8.00 7.70
13 8.00 5.02
14 9.00 8.21
15 7.00 3.00
16 8.00 6.66
17 4.00 4.00
18 8.50
19 9.50 5.22
20 8.00 7.41
21 8.00 5.85
但是当我使用查询时
=Query(Production,"Select A,B,D where A=C",1)
其中 Production 是 A B C 和 D 列的命名范围,我没有得到想要的结果。
结果停在 7 号坦克。 是这样的
Tank No Gross Packed
1 7.00 6.09
2 5.00 5.21
3 7.50 7.03
4 4.00 3.33
5 6.00 2.00
6 7.00 3.11
7 7.00 8.11
如何使用查询或任何其他 sheet 函数获得我想要的结果。 您可以在此处找到包含数据的 sheet:https://docs.google.com/spreadsheets/d/1TQvm1jLktVb3JcMSN5J2oKEbZX9u4iQQ7LQECaPbQAE/edit?usp=sharing
谢谢
复制 A3:B23 到 E3 和 G3 并向下复制以适应:
=iferror(vlookup(E3,C:D,2,0),"")
解决方案:
不是世界上最干净的,但可以解决问题
={
Query({Production},"select Col1,Col2",1),
ArrayFormula(IFERROR(VLOOKUP(QUERY({Production},"select Col1"),
Query({Production},"select Col3,Col4",1),2,0),))
}
与 pnuts 解决方案(最简单的)的区别是
- 此公式仅存在于一个单元格中,并以所需的形式生成报告
- 100% 基于命名范围,因此您可以将它放在任何您想要的地方而不必担心引用