Formula to Identify Duplicates and Get Count

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,214
Office Version
  1. 365
Platform
  1. Windows
Hello,

I need an Excel formula to find duplicates based on two columns (Region/Station) and return the count in the last occurrence. For example, there two duplicates of North/40 so the last occurrence shows 2, likewise there is 4 duplicates for East/20 so the result in the last occurrence shows 4. The ones that are unique should be empty/blank. Please help.

RegionStationResult
East20
North40
South50
East20
North402
East20
East204
 
Works well for a regular data set like the above, but I tried to use it without the LET function (for ease of reading and evaluation) for a Excel table but it gives me the count for each row instead for the last occurrence.
Not sure what you mean by "ease of reading". Using the LET function eliminates redundancy to make the formula shorter and easier to read!
My same formula without using the LET function would look like this:
Excel Formula:
=IF(COUNTIFS(A:A,A2,B:B,B2)=COUNTIFS($A$2:$A2,A2,$B$2:$B2,B2),COUNTIFS(A:A,A2,B:B,B2),"")
You can see how this is shorter and not as hard to read:
Excel Formula:
=LET(x,COUNTIFS(A:A,A2,B:B,B2),IF(x=COUNTIFS($A$2:$A2,A2,$B$2:$B2,B2),x,""))

If you do not understand how the LET function works, see here: LET function - Microsoft Support
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,221,811
Messages
6,162,115
Members
451,743
Latest member
matt3388

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