Search code examples
google-sheets

ArrayFormula, lookup and filter using multiple criteria


I have a Deals column in Result sheet which contains multi deal codes along with its quantities.

I am trying to write an autofilling arrayfomula in Google Sheets. The formula should split each deal code and its quality and look up deal values from Deals sheet, multiply it by its qty and sum it up in each row based on criteria.

I have tried a combination of ArrayFormula, xlookup, and filter, but it doesn't work. It seems like something's wrong with filter function. (Highlighted in red)

criteria lookup

  • Lookup deal values that d.Type equal "all-days" Or
  • date greater than start date, and date lesser than end date

The date from the Result sheet should be between the start date and end date column in the Deals sheet

FILTER({Deals!B$6:B},((Deals!I$6:I<=Result!A6:A)*(Deals!J$6:J>=Result!A6:A))+(Deals!E$6:E="all-day"))

Here is the test sheet

Result sheet

Deals sheet


Solution

  • You may try:

    =map(D6:D,lambda(Σ,if(Σ="",,let(Λ,index(split(tocol(split(Σ,", ",)),"=")),Ξ,index(A:A,row(Σ)), 
     sumproduct(map(choosecols(Λ,1),lambda(Δ,ifna(filter(Deals!G:G,(Deals!B:B=Δ)*((Deals!E:E="all-day")+((Deals!I:I<=Ξ)*(Deals!J:J>=Ξ))))))),iferror(choosecols(Λ,2)))))))
    

    enter image description here