Forum Discussion
Count If formula with no duplicates and one condition
I am using MS Office professional Plus 2016 and I am trying to create a count with the below criteria:
1) Employee name (column E) is not duplicated
and
2) The value in column G is greater than 0
I think I was able to find a formula to get the non-duplicated count for column E using =SUMPRODUCT(($E$6:$E$1991<>"")/COUNTIF($E$6:$E$1991,$E$6:$E$1991&"")) but the number didn't change if I removed some non-duplicate lines.
And a formula to count column G using =COUNTIF($G$6:$G$1991,">0")
but I need it to count column E if there is a number in column G.
See small sample below (there are 12 payrolls) - I was not able to figure out how to upload a sample document.
Column E | EMT/PM | Column G |
Mark | EMT | 8.08 |
Scott | PM | 8.05 |
Tammy | EMT | 24.00 |
Anthony | EMT | 32.43 |
Dean | PM | |
Robert | PM | |
Rylie | EMT | |
LaShawna | EMT | 37.87 |
Joseph | EMT | 15.63 |
John | EMT | 31.55 |
Holly | PM | |
Alexandra | EMT | 8.25 |
Nicole | PM | |
Corinne | PM | |
Jesse | PM | |
Stuart | PM | |
Dean | PM | 32.27 |
Christopher | PM | 25.18 |
Nicholas | EMT | 8.15 |
Mark | EMT | 25.00 |
256.46 | ||
Mark | EMT | 24.52 |
Scott | PM | 16.58 |
Tammy | EMT | 46.60 |
Anthony | EMT | 31.35 |
Jesse | EMT | |
Dean | PM | |
Robert | PM | |
Rylie | EMT | 37.13 |
LaShawna | EMT | 42.80 |
Joseph | EMT | 15.83 |
John | PM | |
Holly | EMT | 16.10 |
Alexandra | PM | |
Nicole | PM | |
Corinne | EMT | |
Madeline | EMT | |
Christopher | EMT | |
Michael | EMT | |
Brittany | PM | |
Jesse | PM | |
Stuart | PM | 22.90 |
Dean | EMT | |
Melissa | PM | 42.78 |
Christopher | EMT | |
Nicholas | EMT | |
Alyssa | EMT | 8.22 |
Mark | EMT | |
Eric | EMT | |
Kenneth |
I guess something like this
I have no Excel 2016 to test, perhaps that could be
=SUMPRODUCT( IF( COUNTIFS( $E$6:$E$1991, $E$6:$E$1991, $G$6:$G$1991, "<>" ), 1 / COUNTIFS($E$6:$E$1991, $E$6:$E$1991 & ""), 0 ) )
or bit shorter
=SUM( IF( COUNTIFS( $E$6:$E$1991, $E$6:$E$1991, $G$6:$G$1991, "<>" ), 1 / COUNTIFS($E$6:$E$1991, $E$6:$E$1991 & ""), 0 ) )
since SUMPRODUCT with IF shall be used as array formula, i.e. you shall enter it with Ctrl+Shift+Enter instead of Enter. If array formula in any case, SUM works the same way.
Please check in attached file.
5 Replies
- SergeiBaklanDiamond Contributor
First formula counts number of duplicates. If count values which appear exactly once (no duplicates) it could be
=SUMPRODUCT( ($E$6:$E$1991<>"")*(COUNTIF($E$6:$E$1991,$E$6:$E$1991&"") = 1 ) )
Count values ignoring blanks
=COUNTIF($G$6:$G$1991,"<>")
- SheilveilCopper ContributorThank you.
I actually do need it to count the duplicates. I'm trying to find the number of employees, therefore each pay period will have duplicates, and I want it to count only those employees in E that have hours in H.- SergeiBaklanDiamond Contributor
I guess something like this
I have no Excel 2016 to test, perhaps that could be
=SUMPRODUCT( IF( COUNTIFS( $E$6:$E$1991, $E$6:$E$1991, $G$6:$G$1991, "<>" ), 1 / COUNTIFS($E$6:$E$1991, $E$6:$E$1991 & ""), 0 ) )
or bit shorter
=SUM( IF( COUNTIFS( $E$6:$E$1991, $E$6:$E$1991, $G$6:$G$1991, "<>" ), 1 / COUNTIFS($E$6:$E$1991, $E$6:$E$1991 & ""), 0 ) )
since SUMPRODUCT with IF shall be used as array formula, i.e. you shall enter it with Ctrl+Shift+Enter instead of Enter. If array formula in any case, SUM works the same way.
Please check in attached file.