Counting Unique Records

Chris Waller

Board Regular
Joined
Jan 18, 2009
Messages
183
Office Version
  1. 365
Platform
  1. Windows
I have an Excel Spreadsheet contains 8,000 rows by 30 columns. I am trying to count the number of National Insurance numbers in column F where column S = FAMC and column T = NP. I am trying to count the occurrence of National Insurance numbers that contain this criteria, however, if the nation insurance number appears multiple times I only want to count the first occurrence. I have tried to filter the data using the information in column S and T, but there are still duplicates displayed. Does anyone know of a formula that would cover this eventuality? TIA.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I have an Excel Spreadsheet contains 8,000 rows by 30 columns. I am trying to count the number of National Insurance numbers in column F where column S = FAMC and column T = NP. I am trying to count the occurrence of National Insurance numbers that contain this criteria, however, if the nation insurance number appears multiple times I only want to count the first occurrence. I have tried to filter the data using the information in column S and T, but there are still duplicates displayed. Does anyone know of a formula that would cover this eventuality? TIA.
One way to do this would be to make a copy of your sheet (right-click sheet tab>Move or Copy), then use Data>Data Tools> Remove Duplicates checking columns F,S & T. Then use the COUNTIFS function with F, S & T ranges as arguments.
 
Upvote 0
I would probably go with Joe's suggestion, but here is a formula that should do what you want.
This is an array formula and must be entered with CTRL-SHIFT-ENTER (command-return on a MAC).
Excel Workbook
EFGRSTUVW
1Ins. #Code1Code2Count
212FMACNP4
315FMACNP
412FMACNP
556tyuNP
612tyufg
776FMACNP
845FMACNP
945FMACNP
1012FMACNP
11
Sheet
 
Upvote 0
Joe,

Thanks for the reply. As I am leave this week I will give it a try when I get back to work, but I understand what you are doing so I will give it a whirl.
 
Upvote 0
Excel Jeannie,

Thanks for the reply. I am leave this week, so I tried about 17 rows containing data in the columns specified. I also did the CTRL+SHIFT+ENTER, but for some reason it didn't count anything.
 
Upvote 0
When you use CTRL-SHIFT_ENTER, Excel should but "{}" around the formula. If you are on a MAC then use COMMAND-RETURN.
Also, check to make sure ranges match your data.
 
Upvote 0
When you use CTRL-SHIFT_ENTER, Excel should but "{}" around the formula. If you are on a MAC then use COMMAND-RETURN.
Also, check to make sure ranges match your data.

I have just tried the same formula on 9 lines of data. I also used CTRL-SHIFT-ENTER and it did put the curly brackets around the formula, but the answer was still 0.
 
Upvote 0
AhoyNC,

In column F there are labels rather than numbers. Would this make any difference?
 
Upvote 0
As you can see in the example below labels would not make a difference.
I'm guessing here, but check to make sure that the data in columns S & T there are no spaces either before or after the FMAC or NP. If it's not finding a match in either or both columns it will return 0.
Excel Workbook
FGQRSTUV
1Ins. #Code1Code2Count
2aFMACNP4
3bFMACNP
4aFMACNP
5ctyuNP
6atyufg
7dFMACNP
8eFMACNP
9eFMACNP
10aFMACNP
Sheet
 
Upvote 0
As you can see in the example below labels would not make a difference.
I'm guessing here, but check to make sure that the data in columns S & T there are no spaces either before or after the FMAC or NP. If it's not finding a match in either or both columns it will return 0.
Excel Workbook
FGQRSTUV
1Ins. #***Code1Code2*Count
2a***FMACNP*4
3b***FMACNP**
4a***FMACNP**
5c***tyuNP**
6a***tyufg**
7d***FMACNP**
8e***FMACNP**
9e***FMACNP**
10a***FMACNP**
Sheet

Excel Jeannie,

Thanks for your earlier replies. I did try your formula once again and it still didn't work. After examining the formula I found that the letters in your formula i.e. for column S had been transposed instead of it being FAMC, it was FMAC. hence the reason it wasn't working. I have changed this and now it appears to work perfectly. Thanks once again for all your help and patience.
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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