Count Duplicates In New Column Same Table

Keith13

New Member
Joined
Oct 6, 2016
Messages
5
I want to count the amount of duplicates and have the corresponding number of duplicates in a column next to it. I need two different version for two different queries and I cant seem to figure it out. Below are two tables of what I need. Please any help would be amazing!!


This table is with one source and counts the number of ID's and puts the correct count in the Duplicate Count Column where it prints outs out the number of duplicates in every row where the duplicate exists. There is also other information in-between ID and Duplicate Count but these are the columns I need it to count the duplicates through the other information can be the same or different.


IDSourceDuplicate Count
1apple2
1apple2
2apple3
2apple3
2apple3
3apple1
4apple1
5apple1

<tbody>
</tbody>



This Table is the same except has different sources that need to be separated

IDSourceDuplicate Count
1apple2
1apple
2
1orange3
3apple2
2orange1
3apple1
1orange3
1orange3
2apple1
3apple2
3orange1

<tbody>
</tbody>
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Welcome to the Board!

If you do an Aggregate (Totals) Query, Grouping on the ID and Source fields, and then doing a Count on any field, it will give you results like this:
IDSourceDuplicate Count
1apple2
2apple3
3apple1
4apple1
5apple1

<tbody>
</tbody>
You can then link this query back to your original table on BOTH the ID and Source fields, if you want to show the duplicated rows like you have in your first example.

If you do not know how to perform an Aggregate (Totals) Query, see here: Access Tips: Calculating Totals in Queries
 
Upvote 0
Thank you I did get them to count. My other Question is how do I link it back to the original table?

I know all this can be done in a macro on excel but I want it all in access so I could just populate the data and when I needed a excel file I could make it and throw it out afterwards and not have to depend on a certain excel file to do the work. Just an FYI
 
Upvote 0
Just create a new query in Access. Add the Aggregate Query you just created and add the original Table.
Create joins between both the ID and Source fields between the two objects, and then select the fields you wish to display.

The following link shows you how to create joins, if you don't know how. You do not need to make it a left join. You can leave it as an inner join (the default option 1).
https://www.techonthenet.com/access/queries/joins2.php
 
Upvote 0

Forum statistics

Threads
1,221,798
Messages
6,162,027
Members
451,737
Latest member
MRASHLEY

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