简体   繁体   English

谷歌表格数组/如果然后

[英]Google Sheets Array/If Then

I need to create a new tab in Google sheets that will look at the table below and only return a row if there is a non-zero value in a particular column.我需要在 Google 表格中创建一个新选项卡,该选项卡将查看下表,并且仅在特定列中有非零值时才返回一行。 For example, on the US tab, there would only be two rows, row 3 and row 6, and it would only include the US column.例如,在 US 选项卡上,只有两行,第 3 行和第 6 行,并且它只包括 US 列。 New data is added to/changed on the source sheet daily so it would need to update automatically.每天都会在源工作表上添加/更改新数据,因此需要自动更新。 Is this possible, and if so, how?这可能吗?如果可以,怎么做?

Date    Description Amount  US     Mexico   Canada  Japan
05/10/21    blue    208.80           2.00       
05/06/21    green   220.00  220.00          
05/04/21    brown   131.00              
05/03/21    black   75.00            22.00      
05/06/21    gray    20.00   30.00             27.00 
05/06/21    orange  82.00               
05/06/21    red    110.00                            23.00

You can do this with a QUERY function.您可以使用QUERY function 执行此操作。

As per my screengrab below, here is an example to go in row I1 :根据我下面的屏幕截图,这是I1行中 go 的示例:

=query({A:G},"select Col1,Col2,Col3 where Col4 >0 order by Col1,Col2 label Col3 'US Amount'",1)

I've put the range A:G inside {} so that I can use the Col1,Col2,Col3 notation rather than A,B,C - helpful if the columns of data might move somewhere else in the sheet and not start in Col A.我已将范围A:G放在{}内,这样我就可以使用 Col1,Col2,Col3 表示法而不是 A,B,C - 如果数据列可能会移动到工作表中的其他位置而不是从 Col 开始,这很有帮助一个。

QUERY is a pseudo SQL and very powerful. QUERY是一个伪 SQL 并且非常强大。

https://support.google.com/docs/answer/3093343?hl=en-GB https://support.google.com/docs/answer/3093343?hl=zh-CN

https://developers.google.com/chart/interactive/docs/querylanguage#language-clauses https://developers.google.com/chart/interactive/docs/querylanguage#language-clauses

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM