Home » excel » Excel countifs on date table column

Excel countifs on date table column

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a excel table, with various columns,
Date, Name, LE, and so on. In LE column values are either L or E.
Date, Name, LE

  • 4/4/2018, Jan, L
  • 4/3/2018, Jed, L
  • 4/1/2018, Jan, L
  • 3/25/2018, Jan, E

Note actual date is like 4/4/2018 but formatted so it display like 4-April-18

Now I want to count how many times L appears for a particular name in a particular month. For example in month of March, ABC has XXX L.

At this time I am adding additional column after date column which display month’s number from date column. But I don’t like to have additional column and finding ways to directly check month from date column.

My formula is like this:
=COUNTIFS(tblXYZ[Name],"ABC", tblXYZ[LE],"L", tblXYZ[Month],"Mar")
It work fine and give required result.

But when I try
=COUNTIFS(tblXYZ[Name],"ABC", tblXYZ[LE],"L", tblXYZ[Date],"Mar")

it don’t work,
when I use MONTH() with table column it don’t work and generate error
=COUNTIFS(tblXYZ[Name],"ABC", tblXYZ[LE],"L", Month(tblXYZ[Date]),3)

so I have to extract month from Date column directly in the formula but I am unable to find a way.

I am using Excel 2013.

How to&Answers:

In general the first parameter of CountIfS() is a range, and pretty much you are trying not to give a range, but an array of months, thus SUMPRODUCT() suits you way better:

COUNIFS support.office.com


This is for a single condition:

=SUMPRODUCT(--MONTH(tblXYZ[Date]=3))

This is for two conditions:

=SUMPRODUCT(--MONTH(tblXYZ[Date]=3)*(tblXYZ[LE]="L"))

The --MONTH(tblXYZ[Date]=3) is a trick, converting boolean data to 0 and 1. You can see how it works with Ribbon>Formulas>Evaluate Formulas in Excel.

Answer:

Try this –

=COUNTIFS(tblXYZ[Name],"ABC", tblXYZ[LE],"L", tblXYZ[Month(Date)],"3")