SOLVED

Count entries on a category omitting duplicates and blank cells

%3CLINGO-SUB%20id%3D%22lingo-sub-172812%22%20slang%3D%22en-US%22%3ECount%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172812%22%20slang%3D%22en-US%22%3EGood%20afternoon%2C%20I%20hope%20you%20can%20help%20me%3CBR%20%2F%3EI'm%20working%20on%20a%20spreadsheet%20of%20injured%20players%20from%20a%20football%20club%2C%20I%20have%20on%20column%20%22A%22%20the%20category%20of%20the%20player%2C%20on%20column%20%22B%22%20the%20name%20of%20the%20players%2C%20and%20on%20column%20%22C%22%20the%20injury.%3CBR%20%2F%3EOn%20another%20sheet%20I%20want%20to%20have%20the%20number%20of%20injured%20players%20for%20every%20category%2C%20so%20I'm%20looking%20for%20a%20formula%20that%20counts%20the%20number%20of%20players%20on%20a%20espec%C3%ADfico%20category%2C%20without%20counting%20the%20duplicates%20and%20without%20crashing%20on%20blank%20spaces.%3CBR%20%2F%3EThe%20only%20thing%20I%20could%20come%20up%20with%20is%20this%3A%3CBR%20%2F%3E%7B%3DSUM(IF(FREQUENCY(IF(IS%20BLANK(injuries!B2%3AB15)%3DFALSE()%2CMATCH(injuries!B2%3AB15%2Cinjuries!B2%3AB15%2C0)%2C%22%22)%2CIF(IS%20BLANK(injuries!B2%3AB15)%3DFALSE()%2CMATCH(injuries!B2%3AB15%2Cinjuries!B2%3AB15%2C0)%2C%22%22))%26gt%3B0%2C1))%7D%3CBR%20%2F%3EWich%20I%20frankly%20don't%20really%20understand%20how%20it%20works%2C%20and%20only%20counts%20the%20total%20of%20injured%20players%2C%20I've%20tried%20to%20nest%20an%20IF(A2%3AB15%3D%22sub%209%22%2C....)%20But%20it%20didn't%20work.%3CBR%20%2F%3E%3CBR%20%2F%3EPlease%20kind%20sirs%2C%20I'm%20in%20need%20of%20your%20knowledge%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-172812%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ecounting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-173067%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-173067%22%20slang%3D%22en-US%22%3E%3CP%3EDoes%26nbsp%3B%3CA%20href%3D%22http%3A%2F%2Fwww.wimjellema.com%2Fadd-this-data-to-the-data-model-check-box-is-greyed-out-in-excel-2016%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%26nbsp%3Bsolve%20your%20issue%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172996%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172996%22%20slang%3D%22en-US%22%3EI%20did%20find%20that%2C%20but%20it%20was%20greyed%20and%20wouldn't%20let%20me%20chek%20it%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172948%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172948%22%20slang%3D%22en-US%22%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F129071%22%20target%3D%22_blank%22%3E%40Vicente%20Heyermann%20Vial%3C%2FA%3Ewrote%3A%3CBR%20%2F%3Esomewhere%20I%20read%20that%20I%20need%20to%20tick%20the%20%22Add%20this%20data%20to%20the%20Data%20Model%22%20option%20when%20creating%20the%20pivot%20Table%2C%20but%20it's%20not%20available%20for%20me.%3CBR%20%2F%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20didn't%20look%20hard%20enough.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20600px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F30507iDB25246EF30EF138%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22dm-add-to-dm%22%20title%3D%22dm-add-to-dm%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172919%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172919%22%20slang%3D%22en-US%22%3EThanks%2C%20it%20sounds%20like%20a%20good%20way%20to%20do%20it%2C%20but%20I%20can't%20manage%20to%20find%20the%20Distinct%20Count%20option%20on%20excel%202016%2C%20somewhere%20I%20read%20that%20I%20need%20to%20tick%20the%20%22Add%20this%20data%20to%20the%20Data%20Model%22%20option%20when%20creating%20the%20pivot%20Table%2C%20but%20it's%20not%20available%20for%20me.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20anyway%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172918%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172918%22%20slang%3D%22en-US%22%3EThank%20you%20very%20much%2C%20your%20formula%20actually%20only%20works%20when%20there%20is%20only%20one%20duplicate%2C%20because%20you%20count%20it%20as%20half%20a%20point%2C%20when%20you%20add%20another%20duplicate%20it%20starts%20increasing%2C%20but%20it%20inspired%20me%20to%20find%20the%20actual%20solution%2C%20instead%20of%20assigning%20a%20value%20of%200.5%20when%20the%20countifs%20is%20%26gt%3B%201%2C%20I%20assigned%20a%20value%20of%201%2Fcountifs%2C%20so%20it%20always%20adds%20to%201%2C%20the%20new%20formula%20is%3A%3CBR%20%2F%3E%7B%3DSUM(IF(COUNTIFS(%24A%242%3A%24A%2411%2CE3%2C%24B%242%3A%24B%2411%2C%24B%242%3A%24B%2411)%26gt%3B1%2C1%2FCOUNTIFS(%24A%242%3A%24A%2411%2CE3%2C%24B%242%3A%24B%2411%2C%24B%242%3A%24B%2411)%2CCOUNTIFS(%24A%242%3A%24A%2411%2CE3%2C%24B%242%3A%24B%2411%2C%24B%242%3A%24B%2411)))%7D%3CBR%20%2F%3E%3CBR%20%2F%3EAgain%2C%20thank%20you%20very%20much%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172869%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172869%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Vicente%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI've%20updated%20the%20formula%20to%20take%20into%20account%20the%20issue%20you%20mentioned%20as%20follows%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3DSUM(IF(COUNTIFS(%24A%242%3A%24A%2411%2CE3%2C%24B%242%3A%24B%2411%2C%24B%242%3A%24B%2411)%26gt%3B1%2C0.5%2CCOUNTIFS(%24A%242%3A%24A%2411%2CE3%2C%24B%242%3A%24B%2411%2C%24B%242%3A%24B%2411)))%3C%2FPRE%3E%0A%3CP%3EBut%20to%20enter%20this%20formula%2C%20you%20have%20to%20press%20%3CSTRONG%3ECtrl%2BShift%2BEnter%3C%2FSTRONG%3Eat%20the%20same%20time%20to%20force%20it%20to%20deliver%20the%26nbsp%3Bcorrect%20result%20because%20it's%20an%20%3CSTRONG%3Earray%3C%2FSTRONG%3Eformula.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20find%20the%20attached%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172865%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172865%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20answer%20Haytham%2C%20but%20I%20think%20I%20might%20have%20not%20expressed%20myself%20clearly%2C%20the%20problem%20with%20your%20formula%20is%20that%20you%20are%20counting%20twice%20Vicente%20Lopez%2C%20in%20the%20list%20players%20who%20had%20more%20than%20one%20injury%20are%20listed%20once%20for%20every%20injury%2C%20but%20I%20need%20to%20count%20the%20number%20of%20players%2C%20so%20I%20don't%20want%20to%20count%20every%20player%20more%20than%20once.%3CBR%20%2F%3EIn%20other%20words%2C%20the%20sub%209%20category%20should%20count%203%20players%2C%20not%204.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172842%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172842%22%20slang%3D%22en-US%22%3E%3CP%3EVicente%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Einsert%20a%20pivot%20table%20and%20%3CU%3Eadd%20it%20to%20the%20data%20model%3C%2FU%3E.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Ecategory%3C%2FSTRONG%3Ein%20rows%20and%20%3CSTRONG%3Ename%3C%2FSTRONG%3Ein%20values.%3C%2FP%3E%0A%3CP%3EChange%20the%20value%20field%20settings%20for%20%3CSTRONG%3Ename%3C%2FSTRONG%3Eto%20%3CSTRONG%3EDistinct%20Count%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEdit%3A%3C%2FP%3E%0A%3CP%3EOne%20more%20thing.%3C%2FP%3E%0A%3CP%3EBlank%20rows%20in%20a%20data%20set%20are%20considered%20bat%20data.%20Remove%20the%20blank%20rows.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-172841%22%20slang%3D%22en-US%22%3ERe%3A%20Count%20entries%20on%20a%20category%20omitting%20duplicates%20and%20blank%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-172841%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBased%20on%20the%20example%20you%20attached%2C%20you%20can%20count%20the%20number%20of%20injured%20players%20by%20counting%20the%20number%20of%20occurrences%20for%20each%20category!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%26nbsp%3Buse%20this%20formula%3A%3C%2FP%3E%0A%3CPRE%3E%3DCOUNTIF(%24A%242%3A%24A%2411%2CE3)%3C%2FPRE%3E%0A%3CP%3EYou%20can%20also%20use%20pivot%20tables%20to%20summarize%20the%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20find%20the%20attached%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor
Good afternoon, I hope you can help me
I'm working on a spreadsheet of injured players from a football club, I have on column "A" the category of the player, on column "B" the name of the players, and on column "C" the injury.
On another sheet I want to have the number of injured players for every category, so I'm looking for a formula that counts the number of players on a específico category, without counting the duplicates and without crashing on blank spaces.
The only thing I could come up with is this:
{=SUM(IF(FREQUENCY(IF(IS BLANK(injuries!B2:B15)=FALSE(),MATCH(injuries!B2:B15,injuries!B2:B15,0),""),IF(IS BLANK(injuries!B2:B15)=FALSE(),MATCH(injuries!B2:B15,injuries!B2:B15,0),""))>0,1))}
Wich I frankly don't really understand how it works, and only counts the total of injured players, I've tried to nest an IF(A2:B15="sub 9",....) But it didn't work.

Please kind sirs, I'm in need of your knowledge
9 Replies
Highlighted

Hi,

 

Based on the example you attached, you can count the number of injured players by counting the number of occurrences for each category!

 

You can use this formula:

=COUNTIF($A$2:$A$11,E3)

You can also use pivot tables to summarize the data.

 

Please find the attached file.

Highlighted

Vicente,

 

insert a pivot table and add it to the data model.

category in rows and name in values.

Change the value field settings for name to Distinct Count.

 

Edit:

One more thing.

Blank rows in a data set are considered bat data. Remove the blank rows.

 

Highlighted
Thanks for your answer Haytham, but I think I might have not expressed myself clearly, the problem with your formula is that you are counting twice Vicente Lopez, in the list players who had more than one injury are listed once for every injury, but I need to count the number of players, so I don't want to count every player more than once.
In other words, the sub 9 category should count 3 players, not 4.
Highlighted

Hello Vicente,

 

I've updated the formula to take into account the issue you mentioned as follows:

 

=SUM(IF(COUNTIFS($A$2:$A$11,E3,$B$2:$B$11,$B$2:$B$11)>1,0.5,COUNTIFS($A$2:$A$11,E3,$B$2:$B$11,$B$2:$B$11)))

But to enter this formula, you have to press Ctrl+Shift+Enter at the same time to force it to deliver the correct result because it's an array formula.

 

Please find the attached file.

 

Highlighted
Solution
Thank you very much, your formula actually only works when there is only one duplicate, because you count it as half a point, when you add another duplicate it starts increasing, but it inspired me to find the actual solution, instead of assigning a value of 0.5 when the countifs is > 1, I assigned a value of 1/countifs, so it always adds to 1, the new formula is:
{=SUM(IF(COUNTIFS($A$2:$A$11,E3,$B$2:$B$11,$B$2:$B$11)>1,1/COUNTIFS($A$2:$A$11,E3,$B$2:$B$11,$B$2:$B$11),COUNTIFS($A$2:$A$11,E3,$B$2:$B$11,$B$2:$B$11)))}

Again, thank you very much
Highlighted
Thanks, it sounds like a good way to do it, but I can't manage to find the Distinct Count option on excel 2016, somewhere I read that I need to tick the "Add this data to the Data Model" option when creating the pivot Table, but it's not available for me.

Thanks anyway
Highlighted

@Vicente Heyermann Vial wrote:
somewhere I read that I need to tick the "Add this data to the Data Model" option when creating the pivot Table, but it's not available for me.

 

You didn't look hard enough.

dm-add-to-dm

Highlighted
I did find that, but it was greyed and wouldn't let me chek it
Highlighted

Does this solve your issue?