Counting Unique Values

jakeman

Active Member
Joined
Apr 29, 2008
Messages
325
Office Version
  1. 365
Platform
  1. Windows
Hello Excel gurus -

I have a spreadsheet with 3 columns that I am looking to count unique values from: User, Task, and DateRange (which I have built as named ranges, btw). What I am trying to do is count the number of unique instances where a user performed a task in a given month.

For example, Joe Smith performed a Task called "Business Analysis" in July. Now, I have the following formula built:

Code:
=(SUMPRODUCT((User="Joe Smith")*(Task="Business Analysis")*(MONTH(DateRange)=7)))

The result I get for just this user is 43. Because Joe performed the same task more than one time, it returns all of the instances but I am only interested in knowing the unique instances, in this case just 1 instance. I have 54 users that I am looking to analyze and determine which users performed a certain task in a given month. When I look at all my team, I see that in July I have 40 out of 54 users who performed the task "Business Analysis" but that is a very manual process for me to do and I have 8 other tasks that I am trying to analyze in the same manner. How can I construct a formula in Excel to evaluate unique instances of a task performed by a user in a single month?

Thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hello Excel gurus -

I have a spreadsheet with 3 columns that I am looking to count unique values from: User, Task, and DateRange (which I have built as named ranges, btw). What I am trying to do is count the number of unique instances where a user performed a task in a given month.

For example, Joe Smith performed a Task called "Business Analysis" in July. Now, I have the following formula built:

Code:
=(SUMPRODUCT((User="Joe Smith")*(Task="Business Analysis")*(MONTH(DateRange)=7)))

The result I get for just this user is 43. Because Joe performed the same task more than one time, it returns all of the instances but I am only interested in knowing the unique instances, in this case just 1 instance. I have 54 users that I am looking to analyze and determine which users performed a certain task in a given month. When I look at all my team, I see that in July I have 40 out of 54 users who performed the task "Business Analysis" but that is a very manual process for me to do and I have 8 other tasks that I am trying to analyze in the same manner. How can I construct a formula in Excel to evaluate unique instances of a task performed by a user in a single month?

Thanks.

Your specs are not very clear...

If you want a unique/distinct of tasks a user has carried out in a particular month/year...
Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(Task<>"",IF(User="Joe Smith",
  IF(DateRange-DAY(DateRange)+1=DATE(2012,7,1),
   MATCH("~"&Task,Task&"",0)))),
    ROW(Task)-ROW(INDEX(Task,1,1))+1),1))

If this is not what you want, please elaborate by means of a very tiny sample.
 
Upvote 0
Aladin - thanks for your reply. Let me start over as I realized my first approach wasn't really evaluating what I needed.

1) I have 9 tasks that I am trying to count:

  1. Business Analysis
  2. Business Implementation
  3. Design Analysis
  4. Operational Readiness
  5. Project Management
  6. Quality Inspection
  7. Solutioning Analysis
  8. Test Execution
  9. Test Planning

2) I have approximately 55 people on a team who may or may not perform any of these tasks in a given month.
3) I want to evaluate the number of unique instances that one of the 55 people performed any of the tasks listed above.
4) My raw data reads like this (just a quick sample):
[TABLE="class: outer_border, width: 500, align: left"]
<TBODY>[TR]
[TD]User
[/TD]
[TD]Task
[/TD]
[TD]Date Performed
[/TD]
[/TR]
[TR]
[TD]Joe Smith
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Paul Jones
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Jim White
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Sue Holmes
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Joe Smith
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
[TR]
[TD]Paul Jones
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
[TR]
[TD]Jim White
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
[TR]
[TD]Sue Holmes
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
</TBODY>[/TABLE]














5) What I am trying to arrive at is to count of the number of unique instances of the task Business Analysis being performed, based upon the users and the date range. So, for example, in July I have 4 unique occurences of Business Analysis in July:
  1. Joe Smith: performed Business Analysis 2x in July but I only count 1
  2. Paul Jones: same as Joe Smith
  3. Jim White: same as Joe Smith
  4. Sue Holmes: same as Joe Smith

I tried my best to explain my specs. Please let me know if you have any follow-up questions.

Thanks for taking a crack at it.

Jake
 
Upvote 0
Aladin - thanks for your reply. Let me start over as I realized my first approach wasn't really evaluating what I needed.

1) I have 9 tasks that I am trying to count:

  1. Business Analysis
  2. Business Implementation
  3. Design Analysis
  4. Operational Readiness
  5. Project Management
  6. Quality Inspection
  7. Solutioning Analysis
  8. Test Execution
  9. Test Planning

2) I have approximately 55 people on a team who may or may not perform any of these tasks in a given month.
3) I want to evaluate the number of unique instances that one of the 55 people performed any of the tasks listed above.
4) My raw data reads like this (just a quick sample):
[TABLE="class: outer_border, width: 500, align: left"]
<tbody>[TR]
[TD]User
[/TD]
[TD]Task
[/TD]
[TD]Date Performed
[/TD]
[/TR]
[TR]
[TD]Joe Smith
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Paul Jones
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Jim White
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Sue Holmes
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/01/2012
[/TD]
[/TR]
[TR]
[TD]Joe Smith
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
[TR]
[TD]Paul Jones
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
[TR]
[TD]Jim White
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
[TR]
[TD]Sue Holmes
[/TD]
[TD]Business Analysis
[/TD]
[TD]7/02/2012
[/TD]
[/TR]
</tbody>[/TABLE]














5) What I am trying to arrive at is to count of the number of unique instances of the task Business Analysis being performed, based upon the users and the date range. So, for example, in July I have 4 unique occurences of Business Analysis in July:
  1. Joe Smith: performed Business Analysis 2x in July but I only count 1
  2. Paul Jones: same as Joe Smith
  3. Jim White: same as Joe Smith
  4. Sue Holmes: same as Joe Smith

I tried my best to explain my specs. Please let me know if you have any follow-up questions.

Thanks for taking a crack at it.

Jake

I guess your point (5) specifies the calculation you need. If so, I already provided this one, as shown below.
Not sure whether (3) is also something that specifies a calculation...
[TABLE="width: 611"]
<tbody>[TR]
[TD="class: xl75, width: 91, bgcolor: white"]User
[/TD]
[TD="class: xl75, width: 128, bgcolor: white"]Task
[/TD]
[TD="class: xl74, width: 136, bgcolor: white"]Date Performed
[/TD]
[TD="class: xl66, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 38, bgcolor: transparent"][/TD]
[TD="class: xl72, width: 188, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl66, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl71, width: 99, bgcolor: white"]User
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent, align: right"]7/1/2012
[/TD]
[/TR]
[TR]
[TD="class: xl72, bgcolor: white"]Joe Smith
[/TD]
[TD="class: xl72, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl73, bgcolor: white"]7/1/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Business Implementation
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl65, bgcolor: transparent"]Joe Smith
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]1
[/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Paul Jones
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/1/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Design Analysis
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl65, bgcolor: transparent"]Paul Jones
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]1
[/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Jim White
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/1/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Operational Readiness
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl65, bgcolor: transparent"]Jim White
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]1
[/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Sue Holmes
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/1/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Project Management
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl65, bgcolor: transparent"]Sue Holmes
[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]1
[/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Joe Smith
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/2/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Quality Inspection
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Paul Jones
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/2/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Solutioning Analysis
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Jim White
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/2/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Test Execution
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl69, width: 91, bgcolor: white"]Sue Holmes
[/TD]
[TD="class: xl69, width: 128, bgcolor: white"]Business Analysis
[/TD]
[TD="class: xl70, width: 136, bgcolor: white"]7/2/2012
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl68, bgcolor: transparent"]Test Planning
[/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[TD="class: xl66, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]

A2:A9 is named User; B2:B9 Task; C2:C9 Date; and F1:F9 TaskList.

H2:H5 houses a set of users of interest.

I1, just enter:
Rich (BB code):
=DATE(2012,7,1)
which specifies the month/year July 2012. You can directly enter in this cell 7/1/2012 instead of a formula which creates that date.

I2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(Task<>"",IF(User=$H2,
  IF(Date-DAY(Date)+1=I$1,
   MATCH("~"&Task,Task&"",0)))),
    ROW(Task)-ROW(INDEX(Task,1,1))+1),1))

Would you assess the foregoing? Also, please elaborate on your (3) if it's a calculation you need.
 
Upvote 0
hi, Jake

A pivot table is another approach - it might be preferable if you have a large amount of data.

The solution is specific to the question and modifies the dataset - using SQL - between the source data and the pivot table. The SQL might be
Code:
SELECT DISTINCT User, Task, Year([Date Performed])+Month([Date Performed])/100 AS [MyDate]
FROM MyData
It is assumed that the source data has a normal defined name 'MyData' & the file is saved. From a new workbook start the pivot table wizard, ALT-D-P, choose external data source, Get Data, Excel files, OK, browse for your file, OK, see the defined name 'MyData', select it, proceed into MS Query and edit the SQL to be as above. 'Open door' to exit MS Query and then finish. Move the fields into the pivot table. Set the data field to be a count, not sum.

Or you could do the same sort of thing with a query table which is fairly similar - a database type approach without formulas.

hth
 
Upvote 0
hi, Jake

A pivot table is another approach - it might be preferable if you have a large amount of data.

The solution is specific to the question and modifies the dataset - using SQL - between the source data and the pivot table. The SQL might be
Code:
SELECT DISTINCT User, Task, Year([Date Performed])+Month([Date Performed])/100 AS [MyDate]
FROM MyData
It is assumed that the source data has a normal defined name 'MyData' & the file is saved. From a new workbook start the pivot table wizard, ALT-D-P, choose external data source, Get Data, Excel files, OK, browse for your file, OK, see the defined name 'MyData', select it, proceed into MS Query and edit the SQL to be as above. 'Open door' to exit MS Query and then finish. Move the fields into the pivot table. Set the data field to be a count, not sum.

Or you could do the same sort of thing with a query table which is fairly similar - a database type approach without formulas.

hth

Fazza - this was very helpful and a distinctive approach to solving my problem. Worked perfectly.

Thank you also, Aladin, for taking the time to respond.

Cheers.
 
Upvote 0
hi, Jake

A pivot table is another approach - it might be preferable if you have a large amount of data.

The solution is specific to the question and modifies the dataset - using SQL - between the source data and the pivot table. The SQL might be
Code:
SELECT DISTINCT User, Task, Year([Date Performed])+Month([Date Performed])/100 AS [MyDate]
FROM MyData
It is assumed that the source data has a normal defined name 'MyData' & the file is saved. From a new workbook start the pivot table wizard, ALT-D-P, choose external data source, Get Data, Excel files, OK, browse for your file, OK, see the defined name 'MyData', select it, proceed into MS Query and edit the SQL to be as above. 'Open door' to exit MS Query and then finish. Move the fields into the pivot table. Set the data field to be a count, not sum.

Or you could do the same sort of thing with a query table which is fairly similar - a database type approach without formulas.

hth

Hello Fazza - I have worked with the code you gave me and have tried to tweak it to my liking but I am having a problem. I'd prefer to use a real date format to roll up the months as opposed to String.

I tried using the Format function in my SQL but I keep getting the error: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1.

I believe it is because the Format function is not supported in SQL for Excel. This is my code:

Code:
SELECT DISTINCT User, `Map Task`, Format([DateMod],"MM-YYYY") AS [MyDate]
FROM Data_Range
WHERE (`Category Type`='Capital Project')

The reason I am trying to do this is so that I can eventuallyroll up the months into Quarters, which is better for my purposes. Do you know of another way to get DateMod to roll up to the month?

Thanks.

Jake
 
Upvote 0
hi, Jake

Addressing your comments.

You "prefer to use a real data format to roll up the months as opposed to String." I didn't use string, I used a decimal number. Your SQL explicitly converts to string. This is a confusing to me but I think a non-issue; or trivial anyway.

Format function is OK.

The error 'too few parameter' indicates a field name in the SQL doesn't exist in the source data. I don't know what your field names are. Earlier in the thread they were [User], [Task], [Date Performed]. Your current SQL refers to fields [User], [Map Task], [DateMod] & [Category Type]. On the face of it, there should be multilple fields unknown to the SQL. Whatever the field names, it should be simple to resolve the current problem.

It should be as simple as aligning the field names used in the SQL with your actual field names. If you don't sort this out readily, please post the field names & I'll have a go at editing the SQL.

regards, Fazza
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,011
Members
452,374
Latest member
keccles

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