谷歌电子表格查询功能列ID不是字母的列 [英] google spreadsheet query function column id other than letter of column

查看:125
本文介绍了谷歌电子表格查询功能列ID不是字母的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的...不知道这些是否可以完成。

我在Google电子表格中使用单元格A1 = time ..范围是A1:C4。



我有一个简单的表格,如下所示:

  
1 bob mike
2 fred pat
3 chris mike

这是我的查询:

  = query($ A $ 1:$ C $ 4,select A,B,C where C =' mike',0)

...非常简单。不过,我希望列引用是动态的。所以我需要能够使用标题进行查询。我该怎么做?我已经尝试了以下方法:

  = query($ A $ 1:$ C $ 4,select'sit','站立'在'站'='迈克',0)

=查询($ A $ 1:$ C $ 4,select sit,stand stand ='mike',0)

以及本页的建议:
Google电子表格查询错误 - 列不存在



还试过以下几种:

  =查询($ A $ 1:$ C $ 4,选择Col2,Col3其中Col3 =' mike',0)

=查询($ A $ 1:$ C $ 4,选择Col2,Col3其中(Col3)='mike',0)

=查询($ A $ 1:$ C $ 4,select(Col2),(Col3)where(Col3)='mike',0)

= query($ A $ 1:$ C $ 4 ,选择'Col2','Col3',其中'Col3'='mike',0)

他们都没有工作......有人知道如何去做或知道这是可能的吗?



https://developers.google.com/chart/interactive/docs/querylanguage



这里的示例看起来像您可以这样做,但仅适用于应用程序脚本?而不是在电子表格函数中?

解决方案

不幸的是,在QUERY电子表格函数select中没有使用标题引用列的本地方式



如果QUERY的第一个参数不是明确引用的范围,您可以使用Colx表示法。实现这一点的一种方法是将括号内的范围包含在内,并调用ArrayFormula:

= ArrayFormula(QUERY(($ A $ 1:$ C $ 4 ),选择Col2,Col3,其中Col3 ='mike',0))



它相当丑陋,但您可以使用(QUERY(($ A $ 1:$ C $ 4),选择Col& amp; $ amp; $ amp; amp; amp; ; MATCH(坐; $ A $ 1:$ C $ 1; 0)&,Col& MATCH(stand; $ A $ 1:$ C $ 1; 0)&Col& MATCH (stand; $ A $ 1:$ C $ 1; 0)&='mike',1))


alright... not sure if these could be done.

i'm in google spreadsheets with cell A1 = time.. the range is A1:C4.

i have a simple table as follows:

time   sit   stand 
1      bob   mike
2      fred  pat
3      chris mike

This my query:

=query($A$1:$C$4,"select A,B,C where C='mike'",0) 

... pretty straight forward. however, I want the column reference to be dynamic. So i need to be able to query using the header. how do i do it? I've already tried the following:

=query($A$1:$C$4,"select 'sit ', 'stand' where 'stand' = 'mike' ",0)

=query($A$1:$C$4,"select sit, stand where stand = 'mike' ",0)

and per this page's suggestion: Google spreadsheet Query Error - column doesn't exist

I've also tried the following:

=query($A$1:$C$4,"select Col2, Col3  where Col3 = 'mike' ",0)

=query($A$1:$C$4,"select Col2, Col3  where (Col3) = 'mike' ",0)

=query($A$1:$C$4,"select (Col2), (Col3)  where (Col3) = 'mike' ",0)

=query($A$1:$C$4,"select 'Col2', 'Col3'  where 'Col3' = 'mike' ",0)

None of them work... does anybody know how to do it or know if it is possible?

https://developers.google.com/chart/interactive/docs/querylanguage

the examples here seems like you can do it, but is that for app script only? and not in the spreadsheet function?

解决方案

Unfortunately there is no native way of referencing columns by their headers in the QUERY spreadsheet function select clause.

You can use the Colx notation if the first argument of the QUERY is anything other than an explicitly referenced range. One way to achieve this is wrap the range in parentheses, and invoking ArrayFormula:

=ArrayFormula(QUERY(($A$1:$C$4),"select Col2, Col3 where Col3 = 'mike'",0))

And it is rather ugly, but you can use the MATCH function to bolt in header references:

=ArrayFormula(QUERY(($A$1:$C$4),"select Col"&MATCH("sit";$A$1:$C$1;0)&", Col"&MATCH("stand";$A$1:$C$1;0)&" where Col"&MATCH("stand";$A$1:$C$1;0)&" = 'mike'",1))

这篇关于谷歌电子表格查询功能列ID不是字母的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆