Answers / Question 15
Notes beside a QUERY or FILTER result attach to the wrong row when results reorder
Manual notes typed next to a live QUERY or FILTER spill stay on fixed rows while the results move. Keep notes in a separate ID-keyed table and look them up.
The problem
A QUERY or FILTER formula builds a live list on one tab. You type notes (or checkboxes, or status) in the columns next to it. When the source data changes—new rows, a different sort, rows dropping out of the filter—the formula results move, but your typed notes stay put. Suddenly each note sits beside the wrong row.
Inspired by a public question on Stack Overflow. The problem above is described in our own words and the solution below is ours.
Why adjacent notes break
A formula spill owns its cells. Anything you type beside it is just ordinary cell content on fixed row numbers. When the spill reorders, row 5's note is still on row 5, even though a different ID is now in that row. There is no built-in “glue” between spill rows and neighboring typed cells.
The fix: a separate Notes table keyed by ID
Give every source row a stable unique ID (order number, email, SKU). Create a Notes tab with two columns: ID and Note. Type every note there. On the QUERY/FILTER results tab, pull the note in with a lookup on the ID column—never by row position.
Assume the live result has the ID in column A starting at A2, and Notes!A:B holds ID and Note:
=IFERROR(VLOOKUP(A2, Notes!$A:$B, 2, FALSE), "")=XLOOKUP(A2, Notes!$A:$A, Notes!$B:$B, "")Fill or array-copy that formula down beside the spill. When the QUERY reorders, each ID still finds its own note.
Adding a new note
- Copy the ID from the results row.
- Paste it into the next empty row of the Notes tab and type the note.
- The lookup on the results tab picks it up immediately.
Optional: protect the results tab so people aren't tempted to type beside the spill, and point them at Notes instead.
FILTER instead of QUERY? Same rule
The same failure happens with FILTER, SORT, SORTN, or any formula that can change which row lands where. Always key manual data by ID and look it up.
=QUERY(Orders!A2:F, "select A, B, C where F = 'Open' order by B", 0)Good to know
- If you don't have a unique ID yet, add one on the source sheet (a UUID, an incrementing number, or a stable order ID from your system) before you start taking notes.
- Blank lookup results usually mean the ID isn't in Notes yet, or the ID types differ (number vs text)—see the VLOOKUP #N/A answer for cleaning those up.
- An alternative when you only need to hide rows, not reshape them: a Filter view on the source tab lets you type notes in place. That only works when you're filtering the source itself, not building a separate QUERY view.
Formulas follow documented Google Sheets / Excel behavior; they aren't machine-tested, so try them on a copy first. Always try new automations on a copy of your sheet first.