excelcountif

Excel COUNTIF every 2nd column within a year


I want to count certain days within a year by value, meaning all the aaa and bbb as shown below, but I cannot figure out how to incorporate that in the formula =COUNTIFS(A1:D20;">="&DATEVALUE("01/01/"&$E$24);A1:D20;"<="&DATEVALUE("31/12/"&E24))

enter image description here


Solution

  • Assuming no Excel-version constraints Screenshot illustrating effect of suggested formula

    =SUM((YEAR(MAP(A1:C20,LAMBDA(n,N(n))))=E24)*((B1:D20="aaa")+(B1:D20="bbb")))
    

    If you have an older version of Excel then you can use this version

    =SUM((YEAR(IF(ISNUMBER(A1:C20),A1:C20))=E24)*((B1:D20="aaa")+(B1:D20="bbb")))
    

    as an array formula.