COUNTIF Unique Dates Between a Range

一笑奈何 提交于 2020-02-02 06:12:45

问题


I am trying to find a way to COUNTIF(S) between a certain set of dates, but only get the count of the unique dates. For context, I am tracking meters over days. I can get more than one instance on the same day with differing meter values. The fact that can happen is screwing up my meters/day average.

Data!A3:A8700 - is the date range.

I am summarizing things monthly, so, in this case, for this example, I'd like something that:

1) Uses COUNTIF (or anything that will work!) between date x and date y. Would like X and Y stored to be pulled from DATA!A3:A8700. In this case, for instance, 11/1/2014 = x and 11/31/2014 = y

2) I would ONLY like to get unique dates as a valid part of the count:

11/1/2014
11/2/2014
11/2/2014
11/3/2014

Would return 3, for instance, not 4.

I have found solutions to get unique numbers in the entire column, but nothing yet for a range within that column. Or, more accurately, I have not been able to figure out how to properly modify those.


回答1:


As far as I understand, you want the following, tell me if I am wrong:



That is, starting from 01/11/2014 that is in D1 and ending in 12/11/2014 that is in D2, you want to calculate unique dates that fall inbetween these two dates in your A1:A100 range.

And in this example, there are 6 unique dates, as shown in result cell D4. Here is the formula to count unique values (dates) in column containing a series of dates.



the formula:

=SUM(IF(FREQUENCY(IF($A$1:$A$97>=D$1;IF($A$1:$A$97<=D$2;IF($A$1:$A$97<>"";MATCH($A$1:$A$97;$A$1:$A$97;0))));ROW($A$1:$A$97)-ROW($A$1)+1);1))



you may need to adjust it according to your regional settings, by replacing ";" with ",".

here is the example excel sheet to download from dropbox.



来源:https://stackoverflow.com/questions/27021006/countif-unique-dates-between-a-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!