Google-sheets – Change default values when Google Forms autofills a Google Sheets

formulasgoogle sheetsgoogle-formsgoogle-sheets-arrayformula

There's a Google form that's linked with a Google sheet: whenever a response is posted to the forme, a new line is added to the sheet (here's a quick tutorial just in case).

Is it possible to have this newly added line to include some formulas?

As an example, say the web form asks for

Name 
Date of birth

Then I'd like the output Google sheet to look like

Name          |  Date of Birth  |  Age
<from form>     <from form>        =TODAY() - B2  

While by default, the third column is created with no value

Best Answer

You will need an array formula for that purpose:

=ARRAYFORMULA(IF(LEN(B2:B), TODAY()-B2:B, ))

or in the first row:

={"header"; ARRAYFORMULA(IF(LEN(B2:B), TODAY()-B2:B, ))}