ARRAYFORMLA()
already has a lot of coverage here as a favorite, and I’m going to give QUERY()
(and the Google Visualization API Query Language!) an honorable mention, then call some attention to the obscure-but-powerful partner to those two: array notation.
Deets here: https://support.google.com/docs/answer/6208276?hl=en
It’s super-easy to understand and use…but it doesn’t really start to shine IMHO until you combine it with those others.
OK, here’s a dirt simple (but mostly useless) example -
={"Portland"; "Seattle"; "Vancouver"}
(separated with semicolons) gives you those three cities in that cell’s column:

and, similarly:
={"Portland", "Seattle", "Vancouver"}
(separated with commas) gives you those three cities in that cell’s row:

I should have stopped here, in the interest of keeping my answer to Ed’s question simple, but as I am prone to do when spreadsheets are involved, when I have a lot of caffeine at lunch, and when I’m excited about something new and cool (like the new Tiller community), I feel a little like getting carried away. So apologies in advance.
Hold.My.Beer.
All that {}
array stuff above was simple, and obvious, and maybe kind of cool – but big deal, though, right? WHY would I use this?
Well, it’s a LOT to swallow in one gulp if you’re not already comfortable using QUERY
and ARRAYFORMULA
, but turns out you can QUERY
those {}
arrays, like the formula below. This beast (I’ve seen a lot worse, though!) gives me the last 365 days’ debit transactions, and adds a formatted month and the start date of each week column, such that I can then reference the resulting data in pivot tables and charts, to see just exactly how much I spent in various categories or at various merchants over the last 365 days - without having to modify my Transactions sheet. In my case, it’s important for me to leave my Transactions sheet alone because like I said, I get carried away - and after about 5 years of working on it, my particular Transactions sheet is probably referenced by like 50 other formulae just like this one, scattered throughout about 10 sheets shared with my wife and a couple of my college-aged children – so if I messed with my Transactions
source sheet, it would probably break a bunch of stuff I’ve already built on top of it and my wife and college age children would call me and ask me what I broke.
But I digress. (a lot, like I said). Here’s that formula that demonstrates one reason I appreciate {}
arrays.
=QUERY({'Transactions'!A:L,
ARRAYFORMULA(TEXT('Transactions'!A:A, "YYYY-MM")),
ARRAYFORMULA('Transactions'!A:A - WEEKDAY('Transactions'!A:A))},
"
SELECT Col1, Col2, Col3, -1 * Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11, Col12, Col13, Col14
WHERE Col1 > DATE '" & TEXT(TODAY()-365, "yyyy-MM-DD") & "'
AND Col4 < 0
LABEL -1 * Col4 'Amount', Col13 'Month', Col14 'Start of Week'
")
Whew! (…hopefully someone chimes in soon with how to enter those carriage returns in a cell, otherwise that sucker gets REALLY hard to read. I love carriage returns almost as much as I love arrays. But I digress further.)
Adding something like this Month
and Start of Week
columns is why I’d use commas, and the following (simpler!) example shows why I might use semicolons. In this case, all I’m doing is combining my manually entered balance history data with my Tiller-fed balance history into a single sheet. The query isn’t strictly necessary in this case, but I use it here to limit the results to the last 365 days. My manually entered balance history (on a separate sheet, creatively named ‘Manually Entered Balance History’) has the exact same column format as Balance History
, and includes such things as the value of my home and car, and the jar of coins I keep buried in my backyard*. Similar to the more complex case above, I have a ton of other ancient sheets that reference my Tiller-fed balance history sheet, and so don’t want to mess with that one directly.
=QUERY({'Balance History'!A:I;
'Manually Entered Balance History'!A:I},
"
SELECT *
WHERE Col1 > DATE '" & TEXT(TODAY()-365, "yyyy-MM-DD") & "'
ORDER BY Col1
")
*I don’t actually have a jar of coins buried in my backyard.