This doesn't directly answer your question about using QUERY
, but I believe that that function might not be the best tool for what you're trying to do.
I write below a solution using the alternative function VLOOKUP
.
I am assuming here that by "Sheet-1" and "Sheet-2", you actually mean entirely different spreadsheets, judging by your use of IMPORTRANGE
.
If you don't mind having a copy of Sheet-1's contents living within Sheet-2, here is what you can do:
- On a new sheet (tab) in Sheet-2, copy this function (fill in
sheet_1_url
):
=IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B")
- You should see a copy of the data from Sheet-1 in that tab. You can hide this tab or protect it if you wish.
- On your main data tab within Sheet-2, copy this formula in your Status column (assuming that your
ID
is in A2:
=IFERROR(VLOOKUP($A2,range_from_step_1,2,),)
- Copy that formula down as much as you need.
However, if you don't want to have a copy of Sheet-1's data in Sheet-2 for whatever reason, you can simply skip steps 1-2 above, going straight to step 3, with the following formula in Sheet-2:
=IFERROR(VLOOKUP($A2,IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B"),2,),)
Not that I recommend it, since you'd technically be importing your data virtually within the formula N number of times, which will be a huge performance hit.
You can see the references for the formulas used above here: