Counting number of unique values in a column

jimithing007

New Member
Joined
Jul 12, 2017
Messages
16
Office Version
  1. 365
I'm having a hard time finding a resolution unique to my situation here.

I am compiling a sales report and I need to determine exactly how many orders my sales people are selling. This report must contain every line item sold, and each order can contain one to many line items. So I have one tab titled "Rep Orders" that looks like this:
1615306903052.png


On my other tab called "Sales by Rep", I need a formula for the B column that looks at the Order# column above, and calculates the total of unique order numbers per each rep (named in the C column above):
1615307006059.png


Thanks in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
What version of Excel are you using?
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’)

Also can you post some sample data.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Thanks for the info. Account details updated. I'm using Office365.

Here is the Rep Orders tab:

Rep Network Orders - MrExcel.xlsx
ABCD
1DateOrder#RepLine Item Sold
21/1/20201001JohnProduct 1
31/1/20201001JohnProduct 2
41/1/20201001JohnProduct 3
51/1/20201001JohnProduct 4
61/1/20201002JohnProduct 1
71/1/20201002JohnProduct 2
81/1/20201002JohnProduct 3
91/1/20201002JohnProduct 4
101/1/20201002JohnProduct 5
111/1/20201002JohnProduct 6
121/2/20201003MikeProduct 2
131/3/20201004SueProduct 7
141/4/20201004SueProduct 8
151/4/20201004SueProduct 9
161/4/20201004SueProduct 10
171/4/20201004SueProduct 11
181/4/20201004SueProduct 12
191/4/20201004SueProduct 13
201/4/20201004SueProduct 14
211/4/20201004SueProduct 15
221/4/20201004SueProduct 16
231/5/20201005DavidProduct 1
241/6/20201006LilyProduct 3
251/6/20201006LilyProduct 4
261/7/20201007RyanProduct 5
271/7/20201007RyanProduct 6
281/7/20201007RyanProduct 7
Rep Orders


And here is my other tab called "Sales by Rep", here's where I need a formula for the B column that looks at the Order# column above, and calculates the total of unique order numbers per each rep (named in the C column above):
Rep Network Orders - MrExcel.xlsx
AB
1RepNo. of Orders sold
2John
3Mike
4Sue
5David
6Lily
7Ryan
Sales by Rep
 
Upvote 0
Thanks for that, how about
+Fluff 1.xlsm
AB
1RepNo. of Orders sold
2John2
3Mike1
4Sue1
5David1
6Lily1
7Ryan1
Stock
Cell Formulas
RangeFormula
B2:B7B2=ROWS(UNIQUE(FILTER('Rep Orders'!$B$2:$B$50,'Rep Orders'!$C$2:$C$50=A2)))
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0
Is there a way to add to this formula so that it looks at the date, and only calculates what's in that date range? 2019 sales only, for example.

also, I'm looking for a formula that only calculates the sum in a given date range.

Rep Orders tab:
Rep Network Orders - MrExcel.xlsx
ABCDE
1DateOrder#RepLine Item SoldOrder Amount
21/1/20181001JohnProduct 1$1,000.00
31/1/20181001JohnProduct 2$1,500.00
41/1/20181001JohnProduct 3$150.00
51/1/20181001JohnProduct 4$20.00
61/1/20181002JohnProduct 1 $3,000.00
71/1/20181002JohnProduct 2$100,000.00
81/1/20181002JohnProduct 3$2,567.00
91/1/20191002JohnProduct 4$40.00
101/1/20191002JohnProduct 5 $1.00
111/1/20191002JohnProduct 6$40.00
121/1/20191003MikeProduct 2$20.00
131/1/20191004SueProduct 7$200.00
141/1/20191004SueProduct 8$600.00
151/1/20191004SueProduct 9$777.00
161/1/20201004SueProduct 10$789.00
171/1/20201004SueProduct 11$1,000.00
181/1/20201004SueProduct 12$111.00
191/1/20201004SueProduct 13$33.00
201/1/20201004SueProduct 14$201.00
211/1/20201004SueProduct 15$2,104.00
221/1/20201004SueProduct 16$14,230.00
231/5/20201005DavidProduct 1$2,342.00
241/6/20201006LilyProduct 3$10,123.00
251/6/20201006LilyProduct 4$120.00
261/7/20201007RyanProduct 5 $31,231.00
271/7/20201007RyanProduct 6$12.00
281/7/20201007RyanProduct 7$31.00
Rep Orders


Sales by Rep tab:
Rep Network Orders - MrExcel.xlsx
ABC
1RepTotal Sales $ for 2019No. of Orders sold in 2019
2John2
3Mike1
4Sue1
5David1
6Lily1
7Ryan1
Sales by Rep
Cell Formulas
RangeFormula
C2:C7C2=ROWS(UNIQUE(FILTER('Rep Orders'!$B$2:$B$50,'Rep Orders'!$C$2:$C$50=A2)))
 
Upvote 0
How about
+Fluff 1.xlsm
ABC
1RepTotal Sales $ for 2019No. of Orders sold in 2019
2John811
3Mike201
4Sue15771
5David0 
6Lily0 
7Ryan0 
Summary
Cell Formulas
RangeFormula
B2:B7B2=SUM(FILTER('Rep orders'!$E$2:$E$50,('Rep orders'!$C$2:$C$50=A2)*(YEAR('Rep orders'!$A$2:$A$50)=2019),0))
C2:C7C2=IFERROR(ROWS(UNIQUE(FILTER('Rep orders'!$B$2:$B$50,('Rep orders'!$C$2:$C$50=A2)*(YEAR('Rep orders'!$A$2:$A$50)=2019)))),"")
 
Upvote 0
Works great! Is there a way to modify the formula so that it looks at the entire column instead of the range (C2:C50, A2:A50, etc.)? This report is likely to have many rows.
 
Upvote 0
It's best to avoid using whole column references as they can bring your workbook to a crawl.
Just change the 50 to a row number that will always be enough to cover your data (without going OTT)
 
Upvote 0

Forum statistics

Threads
1,215,336
Messages
6,124,330
Members
449,155
Latest member
ravioli44

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