将查询正确格式化为Google表格/天气公式

问题描述 投票:0回答:1

我有一个将要与之联系的人,在Google表格中,其中包括“城市”和“州”列。使用该位置,我想确定某个日期的天气和温度,然后将其输入到其自己的单元格中的相应行中。

这是我当前正在使用的公式:

= Query(IMPORTHTML(“ https://www.timeanddate.com/weather/usa/”&Substitute(lower(TRIM(A2)),“”,“-”)&“ / ext”,“表格”,1) ,“选择Col3,Col4,Col5,Col6,Col8,其中Col1 ='”&text(B2,“ DDD”)&Char(10)&text(B2,“ MMM”)&“”&index(split(B2,“ /”) ,1,2)&“'”,2)

导致的结果:

enter image description here

我想这样做:第一行示例。

enter image description here

google-sheets
1个回答
0
投票

尝试:

=ARRAY_CONSTRAIN(QUERY(IMPORTHTML("https://www.timeanddate.com/weather/usa/"&
 SUBSTITUTE(LOWER(TRIM(A2)), " ", "-")&"/ext", "table", 1), 
 "select Col3,Col4,Col5,Col6,Col8 
  where Col1='"&TEXT(B2, "DDD")&CHAR(10)&TEXT(B2, "MMM")&" "&
 INDEX(SPLIT(B2, "/"), 1, 2)&"'", 2), 1, 2)
© www.soinside.com 2019 - 2024. All rights reserved.