Google-sheets – Return a blank when cell reference is blank

formulasgoogle sheets

I am using the following formula in a Google Sheets to calculate the number of days between two dates (dates are in columns G and AL):

=ARRAYFORMULA(if(row(A:A)=1, "Readmission Days", (G:G)-(AL:AL)))

It has to be an array because I am working with a Google Forms and entries are automatically populated into new rows.

The problem is that some of the cells in col AL are blank, so the formula is reading those dates as something else and returning a very large number. Also, when both cells are blank, the formula returns a 0, messing up my data.

How can I include something to ignore blank cells or just return a blank when one or both cell references is blank?

Best Answer

Google Sheets as well as other spreadsheet application handles dates as serialized number. The large number that you refer that is displayed when a cell on AL column is blank is very likely that it is the number that represents the date on the corresponding cell on column G.

Regarding returning a blank, try something like this:

=ArrayFormula(IF(ISBLANK(A:A),,"Non blank"))

Please note that the second argument of the IF() function is left empty (,,): IFS(), IF() and other similar functions return blank when the corresponding argument is empty.