20 Mar Import & Query Data From Another Google Sheets Workbook
If you ever wanted to use Google Sheets as a database, this formula will be your best friend. Here you are able to import data from a second wordbook (i.e. another Sheets file) and then filter & sort that data with a query.
A couple of things to note:
1. The value ‘1HBA2vTrfaYuSQLddsdfjkhJIUYI7NUM5VJPZBuW9OyhpME‘ is the unique reference you your workbook. You will find it in the URL. For example if my URL is https://docs.google.com/a/joeromeo.ca/spreadsheets/d/1nqorh1Q8ylFZdIMNgdsffPZQq5Gu6b2qPzcCSxrs, then the unique ID is 1nqorh1Q8ylFZdIMNgdsffPZQq5Gu6b2qPzcCSxrs
2. SalesData refers to the tab within your workbook
3. You must use the Col1, Col2, etc in your query. Reference the columns by letter does not work. Also the value is case sensitive so you cannot use COL1 or col1
=query(ImportRange("1HBA2vTrfaYuSQL6XUnpJIUYI7NUM5VJPZBuW9OyhpME","SalesData!A2:AB2000"),"SELECT Col1,Col6,Col9,Col26,Col27 where (Col28=5) order by Col9 ")