问题
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