Simple Count question

CHML

Board Regular
Joined
Mar 19, 2023
Messages
57
Office Version
  1. 2019
Platform
  1. Windows
  2. Web
Hi all.
How do I do a Count of groups per last name? attached is part of a spreadsheet. E2 through E7 is one group for Name 1, E8 - E13 is a 2nd group for Name 1 - So Name 1 has 2 groups, Name 2 has one and so on.
I tried iserting a Pivot Table but that gives me a count of all cells in collumn E per Name (12 for name 1 etc.)

Thanking you in advance!
 

Attachments

  • Screenshot 2023-05-16 142100.png
    Screenshot 2023-05-16 142100.png
    37.8 KB · Views: 15

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try:
With Excel 2019 you will need to enter with CTRL-SHIFT-ENTER. Then drag formula down the rows as needed.
Using CTRL-SHIFT-ENTER will put the"{}" around the formula (don't type them in).

Book2
ABCDEF
1LAST NAMEFIRST NAMEGroupLAST NAMECount of Groups
2Last Name 1First Name 1IRELast Name 12
3Last Name 1First Name 1IRELast Name 21
4Last Name 1First Name 1IRELast Name 33
5Last Name 1First Name 1IRE
6Last Name 1First Name 1IRE
7Last Name 1First Name 1IRE
8Last Name 1First Name 1IRF
9Last Name 1First Name 1IRF
10Last Name 1First Name 1IRF
11Last Name 1First Name 1IRF
12Last Name 1First Name 1IRF
13Last Name 1First Name 1IRF
14Last Name 2First Name 2IMH
15Last Name 2First Name 2IMH
16Last Name 2First Name 2IMH
17Last Name 2First Name 2IMH
18Last Name 3First Name 3IMH
19Last Name 3First Name 3IRG
20Last Name 3First Name 3IRG
21Last Name 3First Name 3IRG
22Last Name 3First Name 3IRG
23Last Name 3First Name 3IRG
24Last Name 3First Name 3IRH
25Last Name 3First Name 3IRH
26Last Name 3First Name 3IRH
Sheet1
Cell Formulas
RangeFormula
F2:F4F2=SUM(IF(FREQUENCY(IF($E2=$A$2:$A$26,MATCH($A$2:$A$26&"\"&$C$2:$C$26,$A$2:$A$26&"\"&$C$2:$C$26,0)),ROW($A$2:$A$26)-ROW($A$2)+1),1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
here is another way, also CSE entry:
(and you may need to change the SUM FUNCTION to SUMPRODUCT.


Mr excel questions 35.xlsm
DEFGH
1Last NameGroup
2Last Name 11RELast Name 12
3Last Name 11RELast Name 21
4Last Name 11RELast Name 33
5Last Name 11RE
6Last Name 11RE
7Last Name 11RE
8Last Name 11RF
9Last Name 11RF
10Last Name 11RF
11Last Name 11RF
12Last Name 11RF
13Last Name 11RF
14Last Name 21MH
15Last Name 21MH
16Last Name 21MH
17Last Name 21MH
18Last Name 31XH
19Last Name 31RG
20Last Name 31RG
21Last Name 31RG
22Last Name 31RG
23Last Name 31RG
24Last Name 31RH
25Last Name 31RH
26Last Name 31RH
CHML
Cell Formulas
RangeFormula
H2:H4H2=SUM((--(G2=$D$2:$D$26))*((--($E$2:$E$26<>$E$1:$E$25))+(--($E$2:$E$26<>$E$3:$E$27))))/2
 
Upvote 0
Here is the sumproduct way, and you may not need to use CSE entry.

Mr excel questions 35.xlsm
DEFGHI
1Last NameGroup
2Last Name 11RELast Name 12
3Last Name 11RELast Name 21
4Last Name 11RELast Name 33
5Last Name 11RE
6Last Name 11RE
7Last Name 11RE
8Last Name 11RF
9Last Name 11RF
10Last Name 11RF
11Last Name 11RF
12Last Name 11RF
13Last Name 11RF
14Last Name 21MH
15Last Name 21MH
16Last Name 21MH
17Last Name 21MH
18Last Name 31XH
19Last Name 31RG
20Last Name 31RG
21Last Name 31RG
22Last Name 31RG
23Last Name 31RG
24Last Name 31RH
25Last Name 31RH
26Last Name 31RH
CHML
Cell Formulas
RangeFormula
H2:H4H2=SUMPRODUCT((--(G2=$D$2:$D$26))*((--($E$2:$E$26<>$E$1:$E$25))+(--($E$2:$E$26<>$E$3:$E$27))))/2
 
Upvote 0
Thank you so much, AhoyNC, & Awoohaw. You both did so great! This is from a formula perspective. Is there no option for such a Count using Pivot Table?
 
Upvote 0
There may be a way that you can add a calculated field. Or there may be something with a "MEASURE" from Power Query. I am not an expert on these.
Mr. Excel has a forum for "Power Tools" that you may be able to find some information on Power Query.
 
Upvote 0
To use a pivot table.
Check the box to "Add data to Data Model"
1684298631251.png

Then add Last Name to Rows and Groups to Values in pivot table.
This will give you a count of the groups (not what you want)

Click on the header "Count of Group" and right click.
1684299013284.png

When you right click you will get the following options.
Choose "Summarize Values By" and then "Distinct Count". This will give you the unique count by Last Name.
1684299430079.png


Book2
ABCDEFG
1LAST NAMEFIRST NAMEGroup
2Last Name 1First Name 1IRERow LabelsDistinct Count of Group
3Last Name 1First Name 1IRELast Name 12
4Last Name 1First Name 1IRELast Name 21
5Last Name 1First Name 1IRELast Name 33
6Last Name 1First Name 1IREGrand Total5
7Last Name 1First Name 1IRE
8Last Name 1First Name 1IRF
9Last Name 1First Name 1IRF
10Last Name 1First Name 1IRF
11Last Name 1First Name 1IRF
12Last Name 1First Name 1IRF
13Last Name 1First Name 1IRF
14Last Name 2First Name 2IMH
15Last Name 2First Name 2IMH
16Last Name 2First Name 2IMH
17Last Name 2First Name 2IMH
18Last Name 3First Name 3IMH
19Last Name 3First Name 3IRG
20Last Name 3First Name 3IRG
21Last Name 3First Name 3IRG
22Last Name 3First Name 3IRG
23Last Name 3First Name 3IRG
24Last Name 3First Name 3IRH
25Last Name 3First Name 3IRH
26Last Name 3First Name 3IRH
Sheet4
 
Upvote 1
Solution
Oh! This is precisely what I was trying to gain! Thanks a million, AhoyNC.
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top