Search code examples
google-sheetsgoogle-sheets-formulaformulavlookupspreadsheet

Lookup if the first entry in a set of data matches a particular date


I have a set of columns showing me how much a customer spent on a monthly basis. Each month, a new column is added for the current month. I also have a date selector in order to look at historical data.

I've made a sample sheet to make it easier to understand my problem.

I would need a formula with the following requirements:

  • If a first purchase was done on the month shown with the date selector (in 'Dashboard'!B1), then the customer is considered new. For instance, for this month, if the first entry of a row is in column G, then the customer is new.
  • The reference for the last column is dynamic, as each month, a new column will be added on the right.
  • Customer ID is used as a reference for lookup formula.
  • For rows 2 and 5, customers are never considered new, as we don't have visibility before August 2022.

Please let me know if more information is needed.


Solution

  • Added formula to your sheet:

    =INDEX(IF(LEN(A4:A),IF(INT(B1)=IFNA(VLOOKUP(A4:A,{Data!A2:A,BYROW(Data!B2:Z,LAMBDA(bx,IF(COUNTA(bx)=0,,IF(INDEX(bx,,1)<>"",,+FILTER(Data!B$1:Z$1,bx<>"")))))},2,)),"Yes","No"),))
    

    enter image description here