简体   繁体   English

MS Excel 2010使用多个条件和EDATE计算唯一值

[英]MS Excel 2010 Count unique values with multiple criteria and EDATE

I am trying to get a count of all Unique values listed in Col A, by state and within a date range, for example all records up to the end of April 2018. 我正在尝试按状态并在日期范围内获取列在A列中的所有唯一值的计数,例如直到2018年4月底的所有记录。

I am able to get the count of Unique values by state (result is 2) with the below formula: 我可以使用以下公式按状态(结果为2)获取唯一值的计数:

{=SUMPRODUCT(1*(FREQUENCY(IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0)),ROW($A$2:$A$14)-ROW($A$2))>0))}

but I am unable to get the IF function to work with EDATE. 但我无法使IF函数与EDATE一起使用。 I tried the following but I'm getting 0 as the result. 我尝试了以下操作,但结果为0。 The result should be 1. 结果应为1。

{=SUMPRODUCT(1*(FREQUENCY(IF(D2:D14="<"&EDATE(G1,1),IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0))),ROW($A$2:$A$14)-ROW($A$2))>0))}

I am unable to use Pivot as I need to include date range filter. 我需要使用日期范围过滤器,因此无法使用Pivot。 Could someone please look at my code and tell me what I'm doing wrong? 有人可以看看我的代码,然后告诉我我在做什么错吗? I am using CSE with my formulas. 我在公式中使用CSE。 Thankyou! 谢谢!

I managed to work it out. 我设法解决了。 EDATE wasn't working so I entered the Month date in cell:G1 then referenced it in the IF formula using "<=" eg: IF(D2:D14<=G1). EDATE无法正常工作,因此我在单元格:G1中输入了月份日期,然后在IF公式中使用“ <=”引用了该日期,例如:IF(D2:D14 <= G1)。

Whole array formula is: 整个数组的公式为:

`{=SUMPRODUCT(1*(FREQUENCY(IF(D2:D14<=G1,IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0))),ROW($A$2:$A$14)-ROW($A$2))>0))}

I now receive the correct count of 1, though I have to ensure I have entered the last day of the Month in G1. 现在,我收到的计数正确为1,尽管我必须确保已在G1中输入了本月的最后一天。 State is referenced in F10 and count of unique values is in Column A. 状态在F10中引用,唯一值的计数在A列中。

My full data set is sourced from multiple documents over 5000 rows each and growing daily so my workbook is quite slow to calculate over 1000 array formulas... but it works! 我的完整数据集来自多个文档,每个文档都超过5000行,并且每天都在增长,因此我的工作簿在计算1000个数组公式方面相当慢……但是它可以工作!

If anyone knows of a faster (possibly non-array) formula, I would appreciate the advice! 如果有人知道更快的(可能是非数组)公式,我将不胜感激! Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM