Sum of records unique to row, by column

%3CLINGO-SUB%20id%3D%22lingo-sub-3375809%22%20slang%3D%22en-US%22%3ESum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375809%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20list%20of%20people%20as%20columns%20and%20list%20of%20bird%20species%20as%20rows%2C%20when%20each%20person%20locates%20a%20bird%20species%20they%20put%20an%20X%20under%20their%20column%20name%20aligning%20with%20the%20corresponding%20row%20for%20that%20species.%20If%20someone%20has%20a%20bird%20that%20nobody%20else%20has%20it%20is%20unique%20and%20I%20have%20a%20formula%20that%20identifies%20these%20unique%20records%20and%20colours%20them%20red%20which%20is%20great.%20I'd%20like%20to%20add%20a%20row%20that%20sums%20the%20number%20of%20these%20unique%20records%20to%20show%20how%20many%20unique%20species%20each%20person%20has%20located.%20In%20the%20attached%20shot%20you%20can%20see%20the%20unique%20records%20in%20red-%20is%20there%20a%20simple%20way%2Fformula%20to%20include%20a%20row%20that%20sums%20these%20unique%20observations%20for%20each%20person%3F%20Similar%20to%20the%20total%20species%20observed%2C%20but%20a%20sum%20of%20unique%20species.%20%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F371694i9340D235F6A7CA0D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.PNG%22%20alt%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3EThanks%20for%20any%20help!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3375809%22%20slang%3D%22en-US%22%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-3375846%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375846%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1386472%22%20target%3D%22_blank%22%3E%40VennZenn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20say%20the%20observations%20are%20in%20columns%20B%20to%20AK.%3C%2FP%3E%0A%3CP%3EIn%20the%20next%20available%20column%20AL%2C%20enter%20the%20following%20formula%20in%20row%206%3A%3C%2FP%3E%0A%3CP%3E%3DCOUNTIF(B6%3AAK6%2C%22x%22)%3C%2FP%3E%0A%3CP%3EFill%20down%20to%20the%20last%20used%20row.%20Let's%20say%20that%20this%20is%20row%20100.%3C%2FP%3E%0A%3CP%3EThe%20number%20of%20unique%20observations%20is%3C%2FP%3E%0A%3CP%3E%3DCOUNTIF(AL6%3AAL100%2C1)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375848%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375848%22%20slang%3D%22en-US%22%3EIf%20you%20have%20lambda%20function%2C%20you%20could%20try%20(say%20the%20data%20containing%20%22x%22%20for%20species%20spotted%20is%20in%20B5%3AZ30)%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3DBYCOL((B5%3AZ30%26lt%3B%26gt%3B%22%22)*(BYROW(B5%3AZ30%2C%20LAMBDA(rw%2C%20COUNTA(rw)))%3D1)%2C%20LAMBDA(col%2C%20SUM(col)))%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375850%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375850%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3Bthanks%20for%20your%20reply%2C%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%2C%20that%20didn't%20seem%20to%20work.%20I've%20captured%20another%20screenshot%20here%20showing%20the%20row%2Fcolumns%2C%20the%20last%20row%20of%20data%20is%20829.%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F371696i69DA2998D222F8F4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.PNG%22%20alt%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375851%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375851%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1386472%22%20target%3D%22_blank%22%3E%40VennZenn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20last%20person%20is%20in%20column%20AB%2C%20so%20the%20auxiliary%20formula%20in%20row%206%20should%20be%20%3DCOUNTIF(B6%3AAB6%2C%22x%22)%3C%2FP%3E%0A%3CP%3ELet's%20say%20that%20you%20enter%20this%20formula%20in%20AF6%2C%20then%20fill%20down%20to%20AF829.%3C%2FP%3E%0A%3CP%3EThe%20final%20formula%20then%20becomes%20%3DCOUNTIF(AF6%3AAF829%2C1)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375930%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375930%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1386472%22%20target%3D%22_blank%22%3E%40VennZenn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20365%20solution%20with%20some%20difference%20of%20style%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%20LET(%0A%20%20%20%20%20%20Sum%CE%BB%2C%20%20%20%20%20%20LAMBDA(x%2CSUM(x))%2C%0A%20%20%20%20%20%20obs%2C%20%20%20%20%20%20%20SIGN(observed%3D%22x%22)%2C%0A%20%20%20%20%20%20unique%3F%2C%20%20%20BYROW(obs%2CSum%CE%BB)%3D1%2C%0A%20%20%20%20%20%20uniqueObs%2C%20FILTER(obs%2Cunique%3F)%2C%0A%20%20%20%20%20%20countUniq%2C%20BYCOL(uniqueObs%2C%20Sum%CE%BB)%2C%0A%20%20%20%20%20%20countUniq%0A%20%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375931%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375931%22%20slang%3D%22en-US%22%3EI%20think%20I%20see%20what%20we're%20trying%20to%20do.%20The%20first%20part%20makes%20sense%2C%20and%20I%20now%20have%201s%20in%20each%20row%20where%20unique%20observations%20are%2C%20showing%20in%20column%20AF.%20When%20I%20enter%20the%20second%20formula%20is%20counts%20the%201s%20and%20displays%20in%20the%20cell%20containing%20the%20formula...%20There%20are%2057%20total%201s%2C%20but%20they%20need%20to%20be%20assigned%20to%20be%20split%20into%20each%20person.%20It's%20close%20but%20not%20quite%20there...%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375932%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375932%22%20slang%3D%22en-US%22%3EThanks%20Peter%2C%3CBR%20%2F%3EI'm%20not%20familiar%20with%20lambda%2C%20not%20sure%20where%20to%20enter%20this%20type%20of%20thing%2C%20it%20might%20be%20above%20my%20pay%20grade...%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375933%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375933%22%20slang%3D%22en-US%22%3EIf%20you%20don't%20have%20lambda's%20or%20not%20comfortable%20with%20using%20them%2C%20then%20you%20could%20use%20Hans's%20formula%20in%20column%20AF%20and%20then%20try%20this%20in%20column%20B%20(either%20above%20or%20below%20your%20table)%20and%20then%20copy%20across.%3CBR%20%2F%3E%3CBR%20%2F%3E%3Dsumproduct(--(B6%3AB829%3D%22x%22)%2C%20--(%24AF6%3A%24AF829%3D1))%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375943%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375943%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3BHallelujah%20that%20worked%2C%20thanks%20Hans%20and%20JMB17!%20That%20last%20formula%20looks%20complex%20but%20it%20does%20what%20I%20want%2C%20thanks%20for%20the%20help!%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F371703iD73383C5C2767B40%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.PNG%22%20alt%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3375961%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3375961%22%20slang%3D%22en-US%22%3EI%20probably%20should%20have%20suggested%20countifs%2C%20which%20would%20likely%20be%20more%20familiar.%20But%2C%20either%20one%20should%20work%20for%20you%2C%20I%20think.%3CBR%20%2F%3E%3CBR%20%2F%3E%3Dcountifs(B6%3AB829%2C%20%22X%22%2C%20%24AF6%3A%24AF829%2C%201)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3376367%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20of%20records%20unique%20to%20row%2C%20by%20column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3376367%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1386472%22%20target%3D%22_blank%22%3E%40VennZenn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20fully%20understand%20the%20difficulty.%26nbsp%3B%20The%20code%20only%20works%20with%20Excel%20365%20or%202021%20and%20looks%20completely%20alien.%3C%2FP%3E%3CP%3EFor%20any%20using%20365%2C%20I%20attach%20a%20workbook%20illustrating%20the%20formulae.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Eps%3C%2FEM%3E%20I%20have%20also%20included%20a%20simpler%20version%20of%20the%20formula%20that%20uses%20a%20helper%20range.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi there, 

I have a list of people as columns and list of bird species as rows, when each person locates a bird species they put an X under their column name aligning with the corresponding row for that species. If someone has a bird that nobody else has it is unique and I have a formula that identifies these unique records and colours them red which is great. I'd like to add a row that sums the number of these unique records to show how many unique species each person has located. In the attached shot you can see the unique records in red- is there a simple way/formula to include a row that sums these unique observations for each person? Similar to the total species observed, but a sum of unique species. Capture.PNGThanks for any help! 

11 Replies

@VennZenn 

Let's say the observations are in columns B to AK.

In the next available column AL, enter the following formula in row 6:

=COUNTIF(B6:AK6,"x")

Fill down to the last used row. Let's say that this is row 100.

The number of unique observations is

=COUNTIF(AL6:AL100,1)

If you have lambda function, you could try (say the data containing "x" for species spotted is in B5:Z30):

=BYCOL((B5:Z30<>"")*(BYROW(B5:Z30, LAMBDA(rw, COUNTA(rw)))=1), LAMBDA(col, SUM(col)))

@Hans Vogelaar thanks for your reply, 

Unfortunately, that didn't seem to work. I've captured another screenshot here showing the row/columns, the last row of data is 829. Capture.PNG

@VennZenn 

The last person is in column AB, so the auxiliary formula in row 6 should be =COUNTIF(B6:AB6,"x")

Let's say that you enter this formula in AF6, then fill down to AF829.

The final formula then becomes =COUNTIF(AF6:AF829,1)

@VennZenn 

Another 365 solution with some difference of style

= LET(
      Sumλ,      LAMBDA(x,SUM(x)),
      obs,       SIGN(observed="x"),
      unique?,   BYROW(obs,Sumλ)=1,
      uniqueObs, FILTER(obs,unique?),
      countUniq, BYCOL(uniqueObs, Sumλ),
      countUniq
  )
I think I see what we're trying to do. The first part makes sense, and I now have 1s in each row where unique observations are, showing in column AF. When I enter the second formula is counts the 1s and displays in the cell containing the formula... There are 57 total 1s, but they need to be assigned to be split into each person. It's close but not quite there...
Thanks Peter,
I'm not familiar with lambda, not sure where to enter this type of thing, it might be above my pay grade...
If you don't have lambda's or not comfortable with using them, then you could use Hans's formula in column AF and then try this in column B (either above or below your table) and then copy across.

=sumproduct(--(B6:B829="x"), --($AF6:$AF829=1))

@JMB17 Hallelujah that worked, thanks Hans and JMB17! That last formula looks complex but it does what I want, thanks for the help!Capture.PNG

I probably should have suggested countifs, which would likely be more familiar. But, either one should work for you, I think.

=countifs(B6:B829, "X", $AF6:$AF829, 1)

@VennZenn 

I fully understand the difficulty.  The code only works with Excel 365 or 2021 and looks completely alien.

For any using 365, I attach a workbook illustrating the formulae.

 

 

ps I have also included a simpler version of the formula that uses a helper range.