0
votes

I am trying to count cells in column E that contain the word "Yelp" only for a certain month (January in this case).

As there will be a different number of new patients each month, I cannot set set a range limit e.g E4:E33. As this "E33" number will change, I would like it to be just E (entire column) so we don't have to change the formula manually each month.

I tried different variations of COUNTIFS(MONTH(D4:D), "=1", E4:E, "Yelp") but it doesn't work. Using something like "filter" would requires manually changing the formula each month so I can't use that.

2

2 Answers

1
votes

Try this: First add a column (let's say F) that returns the month of the date (D)

F1=MONTH(D1) (and drag it down)

Then, count:

=COUNTIFS(F:F;4;D:D;'Yelp');

That means: count only when month is 4 and source is Yelp

EDIT:

I assume you'd want to filter by year as well. In that case, add a column that returns the year:

G1=YEAR(D1) (and drag it down), and then:

=COUNTIFS(F:F;4;G:G;2018;D:D;'Yelp');

That means: count only when month is 4, year is 2018 and source is Yelp

EXPLANATION:

Syntax of COUNTIFS is:

COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)

The COUNTIFS function syntax has the following arguments:

criteria_range1 Required. The first range in which to evaluate the associated criteria.

criteria1 Required. The criteria in the form of a number, expression, cell reference, or text that define which cells will be counted. For example, criteria can be expressed as 32, ">32", B4, "apples", or "32".

criteria_range2, criteria2, ... Optional. Additional ranges and their associated criteria. Up to 127 range/criteria pairs are allowed.

From: https://support.office.com/en-us/article/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842

0
votes

Try,

=sumproduct((month(d4:d999)=1)*(e4:e999="yelp"))
'alternate with fully dynamic ranges
=sumproduct((month(d4:index(d:d, match(1e99, d:d)))=1)*(e4:index(e:e, match(1e99, d:d))="yelp"))

Avoid full column references with SUMPRODUCT.

enter image description here