Forum Discussion
Count If formula with no duplicates and one condition
- Jul 24, 2023
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.
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,"<>")
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.
- SergeiBaklanJul 24, 2023Diamond 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.
- SheilveilJul 25, 2023Copper ContributorThis seems to work! thank you!
- SergeiBaklanJul 25, 2023Diamond Contributor
Sheilveil , you are welcome