2016-09-23 70 views
0

我一直在麻烦让查询函数返回0时没有找到查询的数据。谷歌表格查询语言,返回0

鉴于以下数据...

Example Data One

随着每片可被一个不同的球员,我需要计算的每场出场数和那些比赛的结果。

有些玩家可能与彼此处于相同的游戏中,所以游戏ID被赋予一个唯一的标识符,所以这些游戏只计算一次,这部分我有工作。

我现在要做的是记录A队在每个房间里获胜的次数。

Example Data 2

你可以看到在上面的截图我的问题。

Here is the sample sheet有上述数据。

这是用于最右边的例子

=QUERY({QUERY(UNIQUE(QUERY({Sheet1!A2:C;Sheet2!A2:C;Sheet3!A2:C},"select Col1, Col2 where Col2 <> '' and Col3 contains 'A'")),"select Col1, 1");QUERY(QUERY({Sheet1!A2:C;Sheet2!A2:C;Sheet3!A2:C},"select Col1, Col2 where Col2 = '' and Col1 <> '' and Col3 contains 'A'"),"select Col1, 1")},"select Col1, sum(Col2) where Col1 <> '' group by Col1 label sum(Col2) 'TeamA Wins', Col1 'Room'") 

任何人能帮助公式?

回答

1

您可以添加虚拟数据代入公式:

=QUERY(data;{QUERY(UNIQUE(QUERY({Sheet1!A2:C;Sheet2!A2:C;Sheet3!A2:C},"select Col1, Col2 where Col2 <> '' and Col3 contains 'A'")),"select Col1, 1");QUERY(QUERY({Sheet1!A2:C;Sheet2!A2:C;Sheet3!A2:C},"select Col1, Col2 where Col2 = '' and Col1 <> '' and Col3 contains 'A'"),"select Col1, 1")},"select Col1, sum(Col2) where Col1 <> '' group by Col1 label sum(Col2) 'TeamA Wins', Col1 'Room'") 
     ^^^^ 

数据命名的区域,它看起来像这样:

enter image description here

为了使它:

  1. 将数据粘贴到单独的工作表中,如上图所示。
  2. 选择范围A1:B6
  3. Data → Named range →称之为“数据”
  4. 输入公式,它现在应该正常工作。

Sample file有工作公式

+0

此错误显示,当我尝试: http://puu.sh/rkYhB/895e325772.png – NuMs

+0

我已经添加了样本文件 –

+0

作品!再次感谢Max :) – NuMs