Counting Unique Values

errollflynn

New Member
Joined
Jan 25, 2021
Messages
24
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I have a large data set, almost 100k lines, with payroll related data. In addition to employee information, each row has hours worked in a specific pay period, the starting and ending dates of the pay period, and the date the check was issued. In some instances an employee will have worked in multiple locations during one pay period and will have two checks on the same pay date and hence will have two rows with the same pay date. I am trying to find a way to determine how many weeks an employee has worked over the course of the entire data set.

Initially I thought I could use a combination of the pay date, a unique key for the employee and the unique and filter functions to count the unique instances of the pay date in conjunction with the key. I was not able to successfully write the formula and even if I was, I was not sure how to apply it to the entire workbook. I've attached a sample data set and would greatly appreciate any suggestions.
 

Attachments

  • Sample Data.JPG
    Sample Data.JPG
    107.3 KB · Views: 18

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Maybe something like this:

Book1
AEFGHI
1KeyStarting Pay PeriodUnique Key# Weeks
2LNAME200014/24/2022LNAME200014
3LNAME200014/17/2022LNAME2000215
4LNAME200014/10/2022
5LNAME200014/3/2022
6LNAME2000211/13/2022
7LNAME2000211/13/2022
8LNAME2000211/6/2022
9LNAME2000210/30/2022
10LNAME2000210/23/2022
11LNAME2000210/9/2022
12LNAME2000210/2/2022
13LNAME200029/25/2022
14LNAME200029/18/2022
15LNAME200029/4/2022
16LNAME200028/21/2022
17LNAME200027/10/2022
18LNAME200027/10/2022
19LNAME200026/19/2022
20LNAME200026/5/2022
21LNAME200025/29/2022
22LNAME200025/8/2022
23LNAME200025/8/2022
Sheet1
Cell Formulas
RangeFormula
H2:H3H2=UNIQUE(A2:A23)
I2:I3I2=COUNT(UNIQUE(FILTER($F$2:$F$23,$A$2:$A$23=$H2)))
Dynamic array formulas.
 
Upvote 1
Maybe something like this:

Book1
AEFGHI
1KeyStarting Pay PeriodUnique Key# Weeks
2LNAME200014/24/2022LNAME200014
3LNAME200014/17/2022LNAME2000215
4LNAME200014/10/2022
5LNAME200014/3/2022
6LNAME2000211/13/2022
7LNAME2000211/13/2022
8LNAME2000211/6/2022
9LNAME2000210/30/2022
10LNAME2000210/23/2022
11LNAME2000210/9/2022
12LNAME2000210/2/2022
13LNAME200029/25/2022
14LNAME200029/18/2022
15LNAME200029/4/2022
16LNAME200028/21/2022
17LNAME200027/10/2022
18LNAME200027/10/2022
19LNAME200026/19/2022
20LNAME200026/5/2022
21LNAME200025/29/2022
22LNAME200025/8/2022
23LNAME200025/8/2022
Sheet1
Cell Formulas
RangeFormula
H2:H3H2=UNIQUE(A2:A23)
I2:I3I2=COUNT(UNIQUE(FILTER($F$2:$F$23,$A$2:$A$23=$H2)))
Dynamic array formulas.
Worked like a charm! Thank you!
 
Upvote 0
If you are using a spill range with a formula in the top cell inly to get the Unique key list, then perhaps it makes sense to do the same with the 3 Weeks rather than copy the formula down?

23 06 06.xlsm
AEFGHI
1KeyStarting Pay PeriodUnique Key# Weeks
2LNAME2000124/04/2022LNAME200014
3LNAME2000117/04/2022LNAME2000215
4LNAME2000110/04/2022
5LNAME200013/04/2022
6LNAME2000213/11/2022
7LNAME2000213/11/2022
8LNAME200026/11/2022
9LNAME2000230/10/2022
10LNAME2000223/10/2022
11LNAME200029/10/2022
12LNAME200022/10/2022
13LNAME2000225/09/2022
14LNAME2000218/09/2022
15LNAME200024/09/2022
16LNAME2000221/08/2022
17LNAME2000210/07/2022
18LNAME2000210/07/2022
19LNAME2000219/06/2022
20LNAME200025/06/2022
21LNAME2000229/05/2022
22LNAME200028/05/2022
23LNAME200028/05/2022
Unique week count
Cell Formulas
RangeFormula
H2:H3H2=UNIQUE(A2:A23)
I2:I3I2=BYROW(H2#,LAMBDA(rw,COUNT(UNIQUE(FILTER(F2:F23,A2:A23=rw)))))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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