简体   繁体   English

Excel - 基于两列返回唯一值的计数

[英]Excel - Return Count of Unique Values Based on Two Columns

I'm working on a project that has many columns and a few sheets. 我正在开发一个有很多列和几张纸的项目。 For simplicity, I'll post just the ones I'm in need of help for: In a table, I have a username and whether or not they received a certificate. 为简单起见,我将发布我需要帮助的那些:在表格中,我有一个用户名以及他们是否收到证书。 The calculation of the certificate is based on the number of passes they have on other tests (three or more gives them a certificate). 证书的计算基于他们在其他测试中的通过次数(三次或更多次给他们证书)。 On another sheet, I'm posting statistics where I would like to show just the number of unique certificates total. 在另一张表格中,我发布统计信息,我只想显示总数的唯一证书数量。 The table looks something like below (simplified). 该表看起来像下面(简化)。

*Username* | *Test Result* | *Bundle*
abc        | Pass          | ""
abc        | Pass          | ""  
123        | Pass          | True
123        | Pass          | True
123        | Pass          | True
123        | Pass          | True
qwerty     | Fail          | False
qwerty     | Pass          | False
qwerty     | Pass          | False

So with the above, they need three or more tests to have the "Bundle". 因此,如上所述,他们需要三次或更多次测试来获得“捆绑”。 If they pass two and fail the third they get a fail for the "Bundle". 如果他们通过两个并且失败了第三个,他们就会因为“捆绑”而失败。 If they haven't taken three tests, it doesn't count as a pass or fail. 如果他们没有进行三次测试,则不算作通过或失败。

On another sheet, I want to show the number of unique students whom have gotten the "Bundle" and whom haven't . 在另一片,我想告诉的人已经得到了“捆绑”,并为之不是 唯一的学生人数。

Some of the things I've tried: 我试过的一些事情:

=COUNTIFS(MOS_Table[Username],"*",MOS_Table[Bundle],TRUE)

(NOTE: MOS_Table is the name of the table) This will count the total number of TRUE values in the Bundle column but counts the same student for each test they have taken. (注意:MOS_Table是表的名称)这将计算Bundle列中的TRUE值的总数 ,但是对于他们所进行的每个测试都计算相同的学生。

=COUNTIF(MOS_Table[Bundle],TRUE)

This returned the same as above. 返回与上面相同。

I've tried others with SUMPRODUCT and combinations of SUM, COUNTIFS, and other things. 我已经尝试了其他的SUMPRODUCT以及SUM,COUNTIFS和其他东西的组合。 I'm not sure if there's a better way to go about this, but I'll take any hack to get it to work. 我不确定是否有更好的方法来解决这个问题,但我会采取任何措施让它发挥作用。 Long term, there will be up to 400-500 possible rows. 从长远来看,最多可能有400-500行。

Thanks in advance! 提前致谢!

Please try this: 请试试这个:

=SUM(IF(MOS_Table[Bundle]=TRUE,1/COUNTIF(MOS_Table[Username],MOS_Table[Username])))

This is an array-formula and must be confirmed with ctrl + shift + enter ! 这是一个数组公式,必须用ctrl + shift + enter确认

The countif returns an array of the full counts {2,2,4,4,4,4,3,3,3} and the 1/ makes it so it can be summed up, but only for the true part of the IF {FALSE,FALSE,0.25,0.25,0.25,0.25,FALSE,FALSE,FALSE} . countif返回一个完整计数的数组{2,2,4,4,4,4,3,3,3}1/使得它可以总结,但仅适用于IF的真实部分{FALSE,FALSE,0.25,0.25,0.25,0.25,FALSE,FALSE,FALSE} Which is 1 in your example. 在你的例子中哪一个是1。

If you still have any questions, just ask :) 如果您还有任何疑问,请问:)

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

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