IMPORTRANGE with condition

我怕爱的太早我们不能终老 提交于 2020-01-12 11:47:08

问题


Using Google Sheets I want, within the same document, to import data from one sheet to another using IMPORTRANGE with conditions.

I have tried unsuccessfully:

=IF(IMPORTRANGE("https:URL","Inc Database!B2:B300")="permanent",IMPORTRANGE("htps://URL","Inc Database!A2:A300"),"")

and

=QUERY(IMPORTRANGE("https:/URL", "Inc Database!A2:A300"),"SELECT Col1 WHERE Col1 <> 'permanent'")

and

=FILTER(IMPORTRANGE("URL","Inc Database!A1:A250"),IMPORTRANGE("URL","Inc Database!B1:B250"="venture permanent"))

I want the function to say: Import any values from range A that meet criterion "permanent" in range B.

    A    |  B    
_________|_________
 Name    |type 
---------|-------
 Henry   |Permanent
 William |Intern
 John    |Permanent  

回答1:


I have put a few examples in the following spreadsheet:

e.g. =QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1LX7JfbGvgBTfmXsYZz0u5J7K0O6oHJSnBowKQJGa9lY/edit#gid=0", "Inc Database!A2:B300"),"SELECT Col1 WHERE not(Col2 = 'Permanent') ")




回答2:


You need a single quote around the reference to the sheet/tab since there is a space in the name. Using your example:

IMPORTRANGE("https:/URL", "'Inc Database'!A2:A300")

But this will only import column A, so you cannot check against column B

Then use the Query. If you want everything where B is 'Permanent' then you want (untested):

=QUERY(IMPORTRANGE("https:/URL", "'Inc Database'!A2:B"),"SELECT Col1 WHERE Col1 = 'Permanent'")

This will:

  • Import all of the rows, starting at A2 from the main data sheet to use in the Query().
  • Via Query, return only those where Col2 (B) contains 'Permanent'


来源:https://stackoverflow.com/questions/41679844/importrange-with-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!