简体   繁体   English

动态过滤器参数如何使用Query、importrange和indirect一起使用? 或者可以完成任务的东西

[英]How to use Query, importrange, and indirect together for dynamic filter parameters? or something that will do the task

So I'm not sure if I just am not asking the right question while I've been searching for this answer.所以我不确定我在寻找这个答案时是否没有提出正确的问题。

But I'm wishing to change the date and time perimeters to the date and time that is input into a different cell.但我希望将日期和时间范围更改为输入到不同单元格的日期和时间。

=query(importrange("URL", "SEA:A1,CS"), "SELECT Col61, Col97, Col60, Col51, Col50, Col42, Col43, Col49, Col38, Col44: Col41 WHERE (Col3 >= datetime '2021-04-21 21:00:00' AND Col3 <= datetime '2021-4-21 21:50,00') AND ((Col93 = 501)) AND (lower(Col60) contains 'goalie') Order by Col61 desc", TRUE)

Other cells date and time 2021-05-06 21:10:00 and 2021-05-06 22:00:00其他单元格日期和时间 2021-05-06 21:10:00 和 2021-05-06 22:00:00

Result结果

=query(importrange"URL", "SEA:A1,CS"), "SELECT Col61, Col97, Col60, Col51, Col50, Col42, Col43, Col49, Col38, Col44: Col41 WHERE (Col3 >= datetime '2021-05-06 21:10:00' AND Col3 <= datetime '2021-05-06 22:00,00') AND ((Col93 = 501)) AND (lower(Col60) contains 'goalie') Order by Col61 desc", TRUE)

So apparently my question was some how viewed as not clear enough, so ill use a scenario.所以很明显我的问题是一些如何被认为不够清楚,所以我不能使用一个场景。

I have Two separate sheets, Spreadsheet(A) and Spreadsheet(b).我有两个单独的工作表,电子表格(A)和电子表格(b)。 I am using Query with importrange(see above if clarification is needed) to Generate a certain set of values from Spreadsheet(A) Sheet1 to Spreadsheet(B) Sheet1.我正在使用带有 importrange 的查询(如果需要澄清,请参见上文)生成从电子表格(A)Sheet1 到电子表格(B)Sheet1 的一组特定值。

Now in Spreadsheet(B) sheet1 there will two cells dedicated for date entries, lets go with A1 and B1.现在在 Spreadsheet(B) sheet1 中有两个专用于日期条目的单元格,让 go 与 A1 和 B1。 The purpose of these two dates, is to narrow the the data being imported to a specific time frame that is needed by the user.这两个日期的目的是将要导入的数据缩小到用户需要的特定时间范围。

Something like this With A1 and B1 blank像这样的东西 A1 和 B1 空白

  =query(importrange("url", "Sheet1!A1:Z10"), "select Col1, Col2, Col3 where (Col1 > A1 and Col1 < B1)")

Then with 01-01-1111 11:11:11 in A1 abd 02-02-2222 22:22:22 in B2 the function would then change its parameters to然后在 A1 abd 02-02-2222 22:22:22 在 B2 中使用 01-01-1111 11:11:11 function 然后将其参数更改为

  =query(importrange("url", "Sheet1!A1:Z10"), "select Col1, Col2, Col3 where (Col1 > 1111-01-01 11:11:11 and Col1 < 2222-02-02 22:22:22)")

Also i would like to add i attempted to use the INDIRECT function, which worked fine when using query in the same spreadsheet, but would not work when using importrange to query from a different spreadsheet.另外我想补充一点,我尝试使用 INDIRECT function,在同一个电子表格中使用查询时效果很好,但在使用 importrange 从不同的电子表格中查询时不起作用。

If its not clear enough what my question is, can i be given a clear explanation to some how make it more clear?如果我的问题不够清楚,我可以清楚地解释一些如何让它更清楚吗?

if your question is "how to query your data from spreadsheet A depending on dates in spreadsheet B while you are on spreadsheet C" then first you need to run every IMPORTRANGE formula separately to allow access to your spreadsheets A and B. then you can try:如果您的问题是“当您在电子表格 C 上时,如何根据电子表格 B 中的日期从电子表格 A 中查询您的数据”,那么首先您需要分别运行每个 IMPORTRANGE 公式以允许访问您的电子表格 A 和 B。然后您可以尝试:

=QUERY({IMPORTRANGE("URL A"; "SEA!A1:CS")}; 
 select Col61,Col97,Col60,Col51,Col50,Col42,Col43,Col49,Col38,Col44,Col41
 where Col3 >= datetime '"&TEXT(IMPORTRANGE("URL B"; "Sheet1!A1"); "yyyy-mm-dd hh:mm:ss")&"' 
   and Col3 <= datetime '"&TEXT(IMPORTRANGE("URL B"; "Sheet1!B1"); "yyyy-mm-dd hh:mm:ss")&"' 
   and Col93 = 501 
   and lower(Col60) contains 'goalie' 
 order by Col61 desc"; 1)

update更新

=UNIQUE(QUERY(IMPORTRANGE("18AuN0rkrjUe0qK5ATS_MojgK49l5q6wf2nAMVEp54E4", A2&"!A1:FC1000"), 
 "select Col159,Col61,Col97,Col60,Col73,Col66,Col83,Col91,Col78,Col77,Col84,Col75,Col67,Col72,Col92,Col76,Col71,Col69,Col81 
  where Col93 = 501 
    and not lower(Col60) contains 'goalie'
    and Col159 >= datetime '"&TEXT(A3, "yyyy-mm-dd hh:mm:ss")&"'
    and Col159 <= datetime '"&TEXT(A4, "yyyy-mm-dd hh:mm:ss")&"' 
  order by Col3 desc
  label Col159'timestamp'", 1))

在此处输入图像描述

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

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