Counting Value with Multiple Duplicate Entries?

privxls

Board Regular
Joined
Nov 22, 2016
Messages
55
Office Version
  1. 2021
Platform
  1. Windows
Hello,

It has been a while since I've been here on the community, I've had some challenges with life and now I seem to be back on track and I hope everyone here are doing fine and well! I wanted to ask a questions regarding a problem that I am currently facing, I have a sheet where it has multiple duplicates.

I want to count the sort a list that contains duplicates. Now, while I understand that you may say just remove the duplicates, it is a bit tricky as I am not allowed to remove any duplicates. Let me provide you a bit of information about this: The sheet contains list of employees that have processed transactions for customers. I need to get the exact number that the employee has processed a transaction for each customer. The list contains more than 10K data and it's a combination of unique and duplicates. The reason for duplicates is that some customers are repeat customers and they use the same transaction number. See screenshot below:

1668652906533.png


I want to get each employee's number of interactions per customer. Also, I want to get each employee's number of interactions per customer excluding duplicates.

1668652944361.png


I've been playing around =COUNTIFS function and searched all over but can't seem to get an answer.

Hoping someone can help me :)

Thank you.
 

Attachments

  • 1668652849625.png
    1668652849625.png
    27.7 KB · Views: 23
  • 1668652860035.png
    1668652860035.png
    34.3 KB · Views: 25

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Here's a mini-sheet for anyone's reference:

count-dummy file.xlsx
ABCDEFGH
1DateEmployee NameTransaction NumberClient NameEmployee Name# of Customer Interaction
217-Jan-20Lexie500087KHH05tnzABLexie
318-Jan-20Stephon500284YWENe1qQReStephon
418-Jan-20Donald6000834jB8VBYQyxDonald
520-Jan-20Kaylan500155Gw8AccokMCKaylan
620-Jan-20Stephon600145mHWFoYGHBbLonnie
721-Jan-20Lexie600171eMgBrH50wFMavis
822-Jan-20Donald500156yMKo34zeH9Gail
926-Jan-20Lonnie600184uGGSkWARwZParker
1029-Jan-20Mavis500225lYhsZ3Ij6wWhitney
1131-Jan-20Gail600202jH1tX49GCWEthyl
122-Feb-20Gail50001219S6zPkYszMarty
133-Feb-20Kaylan6000147gW1TDTfVfKendyl
144-Feb-20Lonnie500057yfwNJ1P64x
157-Feb-20Parker500159sKcsa879Pa
167-Feb-20Whitney5002884ECUDhRGxy
1711-Feb-20Lexie50012057H88zSO2D
1814-Feb-20Kaylan500039UNxEeht4S1
1914-Feb-20Mavis600252POUQaOmkIa
2019-Feb-20Lonnie500199uT36HiDcZp
2126-Feb-20Gail500249rtOs44cSWo
2226-Feb-20Stephon500018FOuBf0V7nM
2328-Feb-20Ethyl500046xe3AARCZnk
242-Mar-20Parker500000NAxJ66g8Gl
253-Mar-20Gail500110UNxEeht4S1
266-Mar-20Marty500295CoD8PpkZZI
278-Mar-20Stephon500298KjQHSxNxzB
2813-Mar-20Kaylan6000330IyXhlLBzO
2917-Mar-20Marty50006235HGj0R46Z
3018-Mar-20Marty5002148kUptBJuzx
3118-Mar-20Mavis500106mErxoNMT8K
3218-Mar-20Kaylan600042JD4OZJxpeW
3322-Mar-20Gail500213sp4ifBWNFY
3422-Mar-20Kendyl600170Ijo3W57IHH
3526-Mar-20Donald50003424o1xaHseA
3628-Mar-20Donald600215fPJKZnlBVc
3729-Mar-20Mavis600159UDYODC92oR
3830-Mar-20Stephon500202mpPp98ssPE
395-Apr-20Lexie500160RXVJ8uyUFt
406-Apr-20Marty500232A4e7EYwGP5
417-Apr-20Mavis500263iYfVd24etp
429-Apr-20Kendyl600035kn1d7XbKRQ
4313-Apr-20Lexie500189feMpBeoLbn
4413-Apr-20Stephon500114rJa0GkF7Ej
4516-Apr-20Mavis500268D0nOXA0Khw
4616-Apr-20Mavis500131dPcdGzquKR
4718-Apr-20Donald600125bPfqP4Sl6I
4819-Apr-20Kendyl600113yKqY2YeJxf
4920-Apr-20Lexie500037U4h52Y07R5
5023-Apr-20Whitney500233yfwNJ1P64x
Sheet1
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Your question may also be clearer if you include the expected results for that sample data in column H (& for the second question in column I) and post the mini sheet again with any further explanation about how those expected results were obtained manually.

Note too that you can resize the columns to help the mini sheet fit better in your forum post.
 
Upvote 0
Employee Name# of Customer Interaction
Lexie6
Stephon6
Donald5
Kaylan5
Lonnie3
Mavis7
Gail5
Parker2
Whitney2
Ethyl1
Marty4
Kendyl3

If the expected result like above
VBA Code:
Sub test()
    Dim a
    Dim i&
    a = Sheet1.Range("B2:B" & Sheet1.Cells(Rows.Count, 2).End(xlUp).Row)
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
            If a(i, 1) <> 0 Then
                If Not .exists(a(i, 1)) Then
                    .Add a(i, 1), 1
                Else
                    .Item(a(i, 1)) = .Item(a(i, 1)) + 1
                End If
            End If
        Next
             Sheets("Sheet1").Cells(2, 7).Resize(.Count, 2) = Application.Transpose(Application.Index(Array(.keys, .items), 0, 0))
    End With
End Sub
 
Upvote 0
Employee Name# of Customer Interaction
Lexie6
Stephon6
Donald5
Kaylan5
Lonnie3
Mavis7
Gail5
Parker2
Whitney2
Ethyl1
Marty4
Kendyl3

If the expected result like above
VBA Code:
Sub test()
    Dim a
    Dim i&
    a = Sheet1.Range("B2:B" & Sheet1.Cells(Rows.Count, 2).End(xlUp).Row)
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
            If a(i, 1) <> 0 Then
                If Not .exists(a(i, 1)) Then
                    .Add a(i, 1), 1
                Else
                    .Item(a(i, 1)) = .Item(a(i, 1)) + 1
                End If
            End If
        Next
             Sheets("Sheet1").Cells(2, 7).Resize(.Count, 2) = Application.Transpose(Application.Index(Array(.keys, .items), 0, 0))
    End With
End Sub
Thank you Mohadin. Can you please help me understand how the code works? :)
 
Upvote 0
@privxls maybe you missed Peter's post. This can easily be done with a formula depending on your version of Excel
 
Upvote 0
Thanks for that, how about
Fluff.xlsm
ABCDEFGH
1DateEmployee NameTransaction NumberClient NameEmployee Name# of Customer Interaction
217/01/2020Lexie500087KHH05tnzABLexie6
318/01/2020Stephon500284YWENe1qQReStephon6
418/01/2020Donald6000834jB8VBYQyxDonald5
520/01/2020Kaylan500155Gw8AccokMCKaylan5
620/01/2020Stephon600145mHWFoYGHBbLonnie3
721/01/2020Lexie600171eMgBrH50wFMavis7
822/01/2020Donald500156yMKo34zeH9Gail5
926/01/2020Lonnie600184uGGSkWARwZParker2
1029/01/2020Mavis500225lYhsZ3Ij6wWhitney2
1131/01/2020Gail600202jH1tX49GCWEthyl1
1202/02/2020Gail50001219S6zPkYszMarty4
1303/02/2020Kaylan6000147gW1TDTfVfKendyl3
1404/02/2020Lonnie500057yfwNJ1P64x
1507/02/2020Parker500159sKcsa879Pa
1607/02/2020Whitney5002884ECUDhRGxy
1711/02/2020Lexie50012057H88zSO2D
1814/02/2020Kaylan500039UNxEeht4S1
1914/02/2020Mavis600252POUQaOmkIa
2019/02/2020Lonnie500199uT36HiDcZp
2126/02/2020Gail500249rtOs44cSWo
2226/02/2020Stephon500018FOuBf0V7nM
2328/02/2020Ethyl500046xe3AARCZnk
2402/03/2020Parker500000NAxJ66g8Gl
2503/03/2020Gail500110UNxEeht4S1
2606/03/2020Marty500295CoD8PpkZZI
2708/03/2020Stephon500298KjQHSxNxzB
2813/03/2020Kaylan6000330IyXhlLBzO
2917/03/2020Marty50006235HGj0R46Z
3018/03/2020Marty5002148kUptBJuzx
3118/03/2020Mavis500106mErxoNMT8K
3218/03/2020Kaylan600042JD4OZJxpeW
3322/03/2020Gail500213sp4ifBWNFY
3422/03/2020Kendyl600170Ijo3W57IHH
3526/03/2020Donald50003424o1xaHseA
3628/03/2020Donald600215fPJKZnlBVc
3729/03/2020Mavis600159UDYODC92oR
3830/03/2020Stephon500202mpPp98ssPE
3905/04/2020Lexie500160RXVJ8uyUFt
4006/04/2020Marty500232A4e7EYwGP5
4107/04/2020Mavis500263iYfVd24etp
4209/04/2020Kendyl600035kn1d7XbKRQ
4313/04/2020Lexie500189feMpBeoLbn
4413/04/2020Stephon500114rJa0GkF7Ej
4516/04/2020Mavis500268D0nOXA0Khw
4616/04/2020Mavis500131dPcdGzquKR
4718/04/2020Donald600125bPfqP4Sl6I
4819/04/2020Kendyl600113yKqY2YeJxf
4920/04/2020Lexie500037U4h52Y07R5
5023/04/2020Whitney500233yfwNJ1P64x
Main
Cell Formulas
RangeFormula
G2:G13G2=UNIQUE(FILTER(B2:B1000,B2:B1000<>""))
H2:H13H2=ROWS(UNIQUE(FILTER(D2:D1000,B2:B1000=G2)))
Dynamic array formulas.
 
Upvote 0
Thanks for that, how about
Fluff.xlsm
ABCDEFGH
1DateEmployee NameTransaction NumberClient NameEmployee Name# of Customer Interaction
217/01/2020Lexie500087KHH05tnzABLexie6
318/01/2020Stephon500284YWENe1qQReStephon6
418/01/2020Donald6000834jB8VBYQyxDonald5
520/01/2020Kaylan500155Gw8AccokMCKaylan5
620/01/2020Stephon600145mHWFoYGHBbLonnie3
721/01/2020Lexie600171eMgBrH50wFMavis7
822/01/2020Donald500156yMKo34zeH9Gail5
926/01/2020Lonnie600184uGGSkWARwZParker2
1029/01/2020Mavis500225lYhsZ3Ij6wWhitney2
1131/01/2020Gail600202jH1tX49GCWEthyl1
1202/02/2020Gail50001219S6zPkYszMarty4
1303/02/2020Kaylan6000147gW1TDTfVfKendyl3
1404/02/2020Lonnie500057yfwNJ1P64x
1507/02/2020Parker500159sKcsa879Pa
1607/02/2020Whitney5002884ECUDhRGxy
1711/02/2020Lexie50012057H88zSO2D
1814/02/2020Kaylan500039UNxEeht4S1
1914/02/2020Mavis600252POUQaOmkIa
2019/02/2020Lonnie500199uT36HiDcZp
2126/02/2020Gail500249rtOs44cSWo
2226/02/2020Stephon500018FOuBf0V7nM
2328/02/2020Ethyl500046xe3AARCZnk
2402/03/2020Parker500000NAxJ66g8Gl
2503/03/2020Gail500110UNxEeht4S1
2606/03/2020Marty500295CoD8PpkZZI
2708/03/2020Stephon500298KjQHSxNxzB
2813/03/2020Kaylan6000330IyXhlLBzO
2917/03/2020Marty50006235HGj0R46Z
3018/03/2020Marty5002148kUptBJuzx
3118/03/2020Mavis500106mErxoNMT8K
3218/03/2020Kaylan600042JD4OZJxpeW
3322/03/2020Gail500213sp4ifBWNFY
3422/03/2020Kendyl600170Ijo3W57IHH
3526/03/2020Donald50003424o1xaHseA
3628/03/2020Donald600215fPJKZnlBVc
3729/03/2020Mavis600159UDYODC92oR
3830/03/2020Stephon500202mpPp98ssPE
3905/04/2020Lexie500160RXVJ8uyUFt
4006/04/2020Marty500232A4e7EYwGP5
4107/04/2020Mavis500263iYfVd24etp
4209/04/2020Kendyl600035kn1d7XbKRQ
4313/04/2020Lexie500189feMpBeoLbn
4413/04/2020Stephon500114rJa0GkF7Ej
4516/04/2020Mavis500268D0nOXA0Khw
4616/04/2020Mavis500131dPcdGzquKR
4718/04/2020Donald600125bPfqP4Sl6I
4819/04/2020Kendyl600113yKqY2YeJxf
4920/04/2020Lexie500037U4h52Y07R5
5023/04/2020Whitney500233yfwNJ1P64x
Main
Cell Formulas
RangeFormula
G2:G13G2=UNIQUE(FILTER(B2:B1000,B2:B1000<>""))
H2:H13H2=ROWS(UNIQUE(FILTER(D2:D1000,B2:B1000=G2)))
Dynamic array formulas.

Hey @Fluff ,

You're a life saver, the formula worked as intended!

1668891055647.png


I'll make note of this formula from now on :)

By the way, is it okay to ask for additional information from you? I wanted to ask how the formula works? These are the only ones that I understand thus far:

=UNIQUE - provides Unique values on selected column

However, I don't seem to understand the use of =FILTER and the operator "<>", what does B2:B1000 use the "<>" for?. I've tried just using =FILTER and it just lists the exact data from the selected column. So I'm not quite understand the need to do it. Why can I just not use the =UNIQUE function alone?

Also, for =ROWS, what is the need to add it in the formula?

I really appreciate your very kind help <3
 
Upvote 0
The filter is there to remove empty rows so that you don't need to use the exact range of your data.
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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