Arrays 使用google sheets查询处理空格和数据透视中的和

Arrays 使用google sheets查询处理空格和数据透视中的和,arrays,google-sheets,pivot,array-formulas,google-sheets-query,Arrays,Google Sheets,Pivot,Array Formulas,Google Sheets Query,我试图处理谷歌表单中的空白和一行。这是我荒谬的解决方案。我相信,有人有更好的解决办法 ={query({query (query(vd!A:G,"select C,sum(G) where F = 'fm' or F = 'fma' group by C pivot F order by C"),"select Col1"),arrayformula(query (N(query(vd!A:G,"select C,sum(G) where F =

我试图处理谷歌表单中的空白和一行。这是我荒谬的解决方案。我相信,有人有更好的解决办法

={query({query (query(vd!A:G,"select C,sum(G) where F = 'fm' or F = 'fma' group by C pivot F order by C"),"select Col1"),arrayformula(query (N(query(vd!A:G,"select C,sum(G) where F = 'fm' or F = 'fma' group by C pivot F order by C")),"select Col2, Col3"))},"select Col1,Col2,Col3, Col3-Col2 where Col2-Col3 > 50000 or Col2-Col3 < -50000 label Col1 'Program', Col2 'Forecast', Col3 'Actuals', Col3-Col2 'Variance'");{"Total",index(query({query (query(vd!A:G,"select C,sum(G) where F = 'fm' or F = 'fma' group by C pivot F order by C"),"select Col1"),arrayformula(query (N(query(vd!A:G,"select C,sum(G) where F = 'fm' or F = 'fma' group by C pivot F order by C")),"select Col2, Col3"))},"select sum(Col2),sum(Col3), sum(Col3)-sum(Col2) where Col2-Col3 > 50000 or Col2-Col3 < -50000"),2)}}
={query({query(query(vd!A:G,“按C轴选择C,求和(G),其中F='fm'或F='fma'按C轴按C轴按顺序排列”),“select Col1”),数组公式(query(N(query(query(vd!A:G,“选择C,求和(G))其中F='fm'或F='fma'按C轴按C轴按C轴按C顺序排列”),“select Col2,Col3”),“选择Col1、Col2、Col3、Col3-Col2,其中Col2-Col3>50000或Col2-Col3<-50000标签Col1‘程序’、Col2‘预测’、Col3‘实际值’、Col3-Col2‘方差’”;{“总计”、索引(查询({query(查询(vd!A:G),“选择C,求和(G)”,其中F='fm'或F='fma'按C轴分组,按C顺序排列”),“选择Col1”),数组公式(查询(N)(查询(vd!A:G),选择C,求和(G)其中F='fm'或F='fma'按C轴分组(按C轴排序),“选择Col2,Col3”),“选择sum(Col2),sum(Col3),sum(Col3)-sum(Col2),其中Col2-Col3>50000或Col2-Col3<-50000”),2)}
为了便于处理,我查看了这张表。有没有一种简单的方法来命名数据

试试:

=ARRAYFORMULA({"Program", "Forecast", "Actuals", "Variance"; 
 QUERY(QUERY({INDEX(QUERY(vd!A:G,
 "select C,sum(G) 
  where F matches 'fma|fm'
  group by C 
  pivot F 
  order by C"),, 1), 
 QUERY(N(QUERY(vd!A:G, 
 "select C,sum(G) 
  where F matches 'fma|fm'
  group by C 
  pivot F 
  order by C")), 
 "select Col2,Col3")},
 "select Col1,Col2,Col3,Col3-Col2 
  where Col2-Col3 >  50000 
     or Col2-Col3 < -50000", 0), 
 "offset 1", 0); 
 "Total", QUERY(QUERY(QUERY(QUERY({INDEX(QUERY(vd!A:G,
 "select C,sum(G) 
  where F matches 'fma|fm'
  group by C 
  pivot F 
  order by C"),, 1), 
 QUERY(N(QUERY(vd!A:G, 
 "select C,sum(G) 
  where F matches 'fma|fm'
  group by C 
  pivot F 
  order by C")), 
 "select Col2,Col3")},
 "select Col2,Col3,Col3-Col2 
  where Col2-Col3 >  50000 
     or Col2-Col3 < -50000", 0), 
 "offset 1", 0), 
 "select sum(Col1),sum(Col2),sum(Col3)"), 
 "offset 1", 0)})
=数组公式({“计划”、“预测”、“实际值”、“差异”;
查询{INDEX{QUERY(vd!A:G,
“选择C,求和(G)
其中F与“fma | fm”匹配
按C分组
支点F
由C“、1)命令,
查询(N)查询(vd!A:G,
“选择C,求和(G)
其中F与“fma | fm”匹配
按C分组
支点F
(C)命令,
“选择Col2,Col3”)},
“选择Col1、Col2、Col3、Col3-Col2
其中Col2-Col3>50000
或Col2-Col3<-50000“,0),
“偏移量1”,0);
查询{索引}查询{索引{索引},
“选择C,求和(G)
其中F与“fma | fm”匹配
按C分组
支点F
由C“、1)命令,
查询(N)查询(vd!A:G,
“选择C,求和(G)
其中F与“fma | fm”匹配
按C分组
支点F
(C)命令,
“选择Col2,Col3”)},
“选择Col2、Col3、Col3-Col2
其中Col2-Col3>50000
或Col2-Col3<-50000“,0),
“偏移量1”,0),
“选择sum(Col1)、sum(Col2)、sum(Col3)”,
“偏移量1”,0)})

无法使用鼠标移动数据,要避免共享不想共享的数据,您可以做的是:用一些样本虚拟数据复制一份工作表,毕竟社区需要的是通用或样本数据,并且是最少的数据。