Forum Discussion

JennyHoA20181's avatar
JennyHoA20181
Brass Contributor
Jun 22, 2020
Solved

COUNTIFS LESS THAN YEAR 2017 does not work when I use "<"&2017

Hello,

 

My COUNTIFS less than year 2017 formula does not work, please see below and in attached excel the cell highlighted in yellow.

 

=COUNTIFS(Indirect!AI:AI,"Agent",Indirect!AQ:AQ,"<"&2017,Indirect!AR:AR,"0")

 

Thanks!

 

Jenny

7 Replies

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    JennyHoA20181 

    I didn't check the file, but it shall be like

    =COUNTIFS(Indirect!AI:AI,"Agent",Indirect!AQ:AQ,"<2017",Indirect!AR:AR,0)
      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        JennyHoA20181 

        Sorry, was in shortage of time yesterday to check the file carefully.

        You keep years Years and EC previously? flag as texts, not as numbers. With using COUNIFS it always converts criteria parameter from text to number if text represents number (or date). Thus you compare as "2007" < 2007 and since any text is always "more" than any number we have zero result. The workaround is to add soften hyphen before such parameters. Thus the formula could be

        =COUNTIFS(Indirect!AI:AI,"Agent",
                  Indirect!AQ:AQ,"<"&CHAR(173)&"2017",
                  Indirect!AR:AR,CHAR(173)&"0"
        )

        Another option is to use SUMPRODUCT()

Resources