Google Sheets – Report Date/Column Header for First and Last Non-Zero Entries

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-query

I have a sheet with client names (Column A) and the number of visits to the business by mm-yyyy (Columns B – AC). I'm trying to find the first month that they visited the business and the last month we've seen them.

I have attached a screenshot and I have also published a small section of the sheet.

I have been struggling with this for a week and have gotten nowhere. I would greatly appreciate any help.

Click here for Sample Data

Sample

Best Answer

  • paste in cell B3 and drag down:

=ARRAYFORMULA(IFERROR(QUERY(TRANSPOSE(IF(D3:3>0, TO_TEXT($D$1:$1), )), 
 "where Col1 is not null limit 1", 0)))

  • paste in cell C3 and drag down:

=ARRAYFORMULA(IFERROR(QUERY(TRANSPOSE(IF(D3:3>0, TO_TEXT($D$1:$1), )), 
 "where Col1 is not null limit 1 offset "&(COUNTIF(D3:3, ">0")-1), 0)))

0