pivot(?) on number of *unique* order numbers by order taker?

edjusted

New Member
Joined
Oct 16, 2014
Messages
14
I have a report that shows each line item on open orders as it's own row.

So let's say there are 3 orders with 3 items each. The report would have 9 rows and might look something like this:
Order #Order takerItemQty
123Bobstuff2
123Bobstuff2
123Bobstuff2
222Janestuff2
222Janestuff2
222Janestuff2
333Bobstuff2
333Bobstuff2
333Bobstuff2

<tbody>
</tbody>


What I ultimately want to see is a table that shows me how many unique orders each order taker has. In this case, it might look something like:
Bob: 2
Jane: 1

I can do a pivot using Order Taker and Order Number as the rows, and see:
Bob
123
333
Jane
222

But I can't figure out how to see how many individual orders each person has. Is there a way to do this?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
In the pivot table, you can just do Order taker in the rows and Order taker (count) in the values. That will give you a unique value count for all the people who are listed as taking orders.
 
Upvote 0
Thanks AFPathfinder. That doesn't seem to give me the right numbers. With my example, I'm looking for:
Bob: 2
Jane: 1

But putting Order taker (count) in the values (or Order *number* (count)) gives me the number of rows, i.e.:
Bob: 6
Jane: 3

..because Bob shows up in 6 rows and Jane shows up in 3.

Maybe I'm misinterpreting what you're saying?
 
Upvote 0
Oops! I misread your post. I think you'd need to copy and paste a new table to perform the remove duplicates. However, if you plan on using those items and quantities, that wouldn't be the best option. If you don't have many names, you could just build a new table out of COUNTIFS/SUMIFS. VBA would be a viable option, as well.
 
Upvote 0
If you're interested in a macro, how about
Code:
Sub GetQty()

   Dim Cl As Range
   Dim Itm As Variant
   Dim Rw As Long
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("B2", Range("B" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) Then
            .Add Cl.Value, Cl.Offset(, -1).Value
         ElseIf InStr(.Item(Cl.Value), Cl.Offset(, -1)) = 0 Then
            .Item(Cl.Value) = .Item(Cl.Value) & "," & Cl.Offset(, -1).Value
         End If
      Next Cl
      Range("G2").Resize(.Count).Value = Application.Transpose(.keys)
      Rw = 2
      For Each Itm In .items
         Range("H" & Rw).Value = UBound(Split(Itm, ",")) + 1
         Rw = Rw + 1
      Next Itm
   End With
         
End Sub
 
Upvote 0
Or maybe
Code:
Sub GetQty2()

   Dim Cl As Range
   Dim Ky As Variant
   Dim Rw As Long
   Dim Dic As Object
   Dim Nme As String
   Dim Ord As String
   
   Set Dic = CreateObject("scripting.dictionary")
   For Each Cl In Range("B2", Range("B" & Rows.Count).End(xlUp))
      Nme = Cl.Value
      Ord = Cl.Offset(, -1).Value
      If Not Dic.exists(Nme) Then
         Dic.Add Nme, CreateObject("scripting.dictionary")
         Dic(Nme).Add Ord, Nothing
      ElseIf Not Dic(Nme).exists(Ord) Then
         Dic(Nme).Add Ord, Nothing
      End If
   Next Cl
   Rw = 2
   For Each Ky In Dic.keys
      Range("G" & Rw).Value = Ky
      Range("H" & Rw).Value = Dic(Ky).Count
      Rw = Rw + 1
   Next Ky

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

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