简体   繁体   English

如何在 Google Sheets 中结合 QUERY 获取 ARRAY 公式的来源

[英]How to get the source of an ARRAY formula combined with QUERY in Google Sheets

I have a Spreadsheet where each tab is a month (January, February, ..., December) and they have exactly the same structure.我有一个电子表格,其中每个选项卡都是一个月(一月、二月、...、十二月),它们的结构完全相同。

In order to combine all the information in a single sheet I used an array:为了将所有信息组合在一张纸中,我使用了一个数组:

={January!A5:Q;February!A5:Q;March!A5:Q;April!A5:Q;May!A5:Q;June!A5:Q;July!A5:Q;August!A5:Q;September!A5:Q;October!A5:Q;November!A5:Q;December!A5:Q}

But I wanted to filter the entries of each month based on some conditions, so I used the QUERY function:但是我想根据一些条件过滤每个月的条目,所以我使用了 QUERY 函数:

=QUERY({January!A5:Q;February!A5:Q;March!A5:Q;April!A5:Q;May!A5:Q;June!A5:Q;July!A5:Q;August!A5:Q;September!A5:Q;October!A5:Q;November!A5:Q;December!A5:Q},"select * where Col3 = 'X'",0)

I get the desired result.我得到了想要的结果。 The extra plus that I want to achieve is to identify the month at each line belongs, in other words, the sheet were the data is pulled.我想要实现的额外加分是确定每一行所属的月份,换句话说,是数据被拉出的工作表。 And I want to see that without adding columns or extra fields on the source sheets.而且我希望在源表上不添加列或额外字段的情况下看到这一点。

How do I do that?我怎么做?

try:尝试:

=ARRAYFORMULA(QUERY({
 January!A5:Q,   January!Z5:Z&"January"; 
 February!A5:Q,  February!Z5:Z&"February"; 
 March!A5:Q,     March!Z5:Z&"March";     
 April!A5:Q,     April!Z5:Z&"April"; 
 May!A5:Q,       May!Z5:Z&"May";
 June!A5:Q,      June!Z5:Z&"June"; 
 July!A5:Q,      July!Z5:Z&"July"; 
 August!A5:Q,    August!Z5:Z&"August";  
 September!A5:Q, September!Z5:Z&"September";
 October!A5:Q,   October!Z5:Z&"October";
 November!A5:Q,  November!Z5:Z&"November";
 December!A5:Q,  December!Z5:Z&"December"}
 "where Col3 = 'X'", 0))

where column Z is an empty column其中Z列是空列

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

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