In this article, you’ll see how to use Array Formulas with Google Forms data to automatically calculate running metrics on your data.
Have you ever tried to use a formula in a column adjacent to your form responses to do calculations? You’ve copied it to the bottom of your sheet, maybe even included an IF statement for the blank rows, and now you want it to auto-calculate whenever new responses come in.
Sadly, this approach doesn’t work.
When a response is collected through the form it adds a new row under your existing data, and any formulas in adjacent columns get bumped down a row rather than being calculated. Bummer!
However, this is a perfect use case for an Array Formula (never heard of these before? Check out: How do array formulas work in Google Sheets?).
In the example above, I’ve set up a simple Google Form which asks a user to submit a single number between 1 and 100. The form responses are collected in columns A and B of a Google Sheet (timestamp and number respectively).
The other columns contain Array Formulas with Google Forms data to calculate various metrics e.g. running totals, %, average etc. (all made-up for the purposes of this example).
Using Array Formulas with Google Forms data, we create a single formula in the top row of Sheet, which will automatically perform calculations on any new rows of response data from the Google Form.
Note: in general, and especially if your forms are complex, you should consider keeping the response data in its own sheet, and doing any data analysis in a separate sheet.
How to use Array Formulas with Google Forms data
What’s the formula?
Array Cumulative SUM: To get the total of all values in column B, enter this formula in the top row (e.g. cell C2):
Array % of TOTAL: To calculate the % of values in column B, enter this formula in the top row (e.g. cell D2):
Array Average: To calculate the average of all values in column B, enter this formula in the top row (e.g. cell E2):
Array IF: To create categories for values in column B, enter this formula in the top row (e.g. cell F2):
=ArrayFormula(IF(ISBLANK($B$2:$B),IFERROR(1/0),IF($B$2:$B > 50,"Large","Small")))
All of these will expand to fill out the entire column, displaying values for any rows that have numbers in column B. They will auto-update when new data arrives through the Google Form.
Can I see an example worksheet?
Here’s the link to the Google Form so you can see the formulas auto-update.
How does this formula work?
Let’s run through how the first of these array formula examples, the SUM example, works.
The way to think of it is that in the first row, we effectively have this formula:
This regular formula checks if cell B2 is blank or not.
If it’s blank then the
ISBLANK formula returns
TRUE and our IF formula outputs the results of the IFERROR fucntion: IFERROR(1/0) in cell C2, in other words a blank cell.
However, if cell B2 has a number in it (from the Form), then we put the total of column B into cell C2. The syntax
SUM(B2:B) ensures that we include ALL numbers in column B into our total calculation.
Now consider the next row, where our formula effectively becomes:
It’s identical except we’re checking row 3, so whether
B3 is blank or not, and outputting the
IF result into cell
Finally, we turn it into an array formula by putting a range into the
IF ISBLANK test, and wrapping with the ArrayFormula syntax:
You only enter this formula once, into cell
C2 (or whatever your top row is) and it will auto-fill the whole column.
Whenever a form response is added to the Sheet, a new number appears in column B and that cell is no longer blank. Hence the array formula updates to display the
SUM value into the adjacent cell in column C.