Formula to count how many different days someone worked

luckeyjune

New Member
Joined
Jun 28, 2021
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I'm stumped on this seemingly simple request. Basically I have a dataset with a column for name, another for job #, and another for date. Each name has multiple rows with the same date, since there are multiple jobs for day. I want a sum of unique dates each person worked for the month so far. Basically just a sum of worked days. Suggestions for going about this in an easy way? I figured I'd make a pivot of unique names, and do a vlookup helper column next to the pivot of unique names with a count of their workdays. Thanks so much for any and all suggestions!!
 

Attachments

  • mrexcel example.JPG
    mrexcel example.JPG
    42.9 KB · Views: 9

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
MrExcelPlayground2.xlsm
JKLMN
1DatePersonDate Range
26/2/2021John6/1/2021John2
36/2/2021John6/30/2021Mary3
46/6/2021JohnFred2
56/2/2021Mary
66/2/2021Mary
76/3/2021Mary
86/4/2021Mary
96/1/2021Fred
106/1/2021Fred
116/2/2021Fred
Sheet36
Cell Formulas
RangeFormula
N2:N4N2=SUM(--NOT(ISNA(VLOOKUP(ROW(INDIRECT($L$2&":"&$L$3)),IF($K$2:$K$11=M2,$J$2:$J$11,""),1,FALSE))))
 
Upvote 0
MrExcelPlayground2.xlsm
JKLMN
1DatePersonDate Range
26/2/2021John6/1/2021John2
36/2/2021John6/30/2021Mary3
46/6/2021JohnFred2
56/2/2021Mary
66/2/2021Mary
76/3/2021Mary
86/4/2021Mary
96/1/2021Fred
106/1/2021Fred
116/2/2021Fred
Sheet36
Cell Formulas
RangeFormula
N2:N4N2=SUM(--NOT(ISNA(VLOOKUP(ROW(INDIRECT($L$2&":"&$L$3)),IF($K$2:$K$11=M2,$J$2:$J$11,""),1,FALSE))))
Thank you so much for your reply. When I try to implement this in my actual sheet, it's not working.. I think this might be due to the date field in the original dataset not being formatted as a date. It would be nice to find a way that doesn't require the date range, and can somehow just count unique values by name.
 
Upvote 0
I added a bunch of helper columns (2 for each person). It allows you to ignore the date range. You can ignore columns L and N here.

MrExcelPlayground2.xlsm
JKLMNOPQRSTU
1DatePersonDate RangeHelper Columns for each person
26/2/2021John6/1/2021John2244349  443494434944348
36/2/2021John6/30/2021Mary3344349443534435044349
46/6/2021JohnFred2244353 44351 
56/2/2021Mary44349   
66/2/2021Mary44349   
76/3/2021Mary44350   
86/4/2021Mary44351   
96/1/2021Fred44348   
106/1/2021Fred44348   
116/2/2021Fred44349   
Sheet36
Cell Formulas
RangeFormula
N2:N4N2=SUM(--NOT(ISNA(VLOOKUP(ROW(INDIRECT($L$2&":"&$L$3)),IF($K$2:$K$11=M2,$J$2:$J$11,""),1,FALSE))))
O2O2=COUNT(S2:S11)
P2:P11P2=IF(K2:K11=M2,J2:J11,"")
Q2:Q11Q2=IF(K2:K11=M3,J2:J11,"")
R2:R11R2=IF(K2:K11=M4,J2:J11,"")
S2:U11S2=IFERROR(INDEX(P$2#,MATCH(0,INDEX(COUNTIF(S$1:S1,P$2#),0,0),0)),"")
O3O3=COUNT(T2:T11)
O4O4=COUNT(U2:U11)
Dynamic array formulas.


Excel 365s "UNIQUE" function would make quick work of this.

Other clever folk on here might be able to do this more elegantly.
 
Upvote 0
Another option
+Fluff 1.xlsm
ABCDE
1DatePerson
202/06/2021JohnJohn2
302/06/2021JohnMary3
406/06/2021JohnFred2
502/06/2021Mary
602/06/2021Mary
703/06/2021Mary
804/06/2021Mary
901/06/2021Fred
1001/06/2021Fred
1102/06/2021Fred
12
List
Cell Formulas
RangeFormula
E2:E4E2=SUM(--(FREQUENCY(IF($B$2:$B$11=D2,$A$2:$A$11),$A$2:$A$11)>0))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thank you so much for these interesting solutions! Because in my original dataset I have so many names and dates, after attempting the options presented here I decided to do a pivot on another tab, with a column for name, and another for date. I made it so the pivot repeats the column label for name on each line to enable the ability to vlookup. I put a helper column to the right of the pivot and use COUNTIF to count how many times the name appears, which will in turn count the unique dates, since the pivot only shows unique dates. Then in my original data I did a VLOOKUP for name, and pulled in the day #. That way I can pivot the entire dataset. Maybe not that elegant, but I think this is the easiest for me to maintain when running this report weekly. Thank you everyone for your help. I learn a LOT from this site.
 

Attachments

  • Screenshot (76).png
    Screenshot (76).png
    32.9 KB · Views: 3
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0
Glad you sorted it & thanks for the feedback.
Thank you so much. I am going to save your formula idea in my little catalogue of formulas I keep in notepad though. I am sure I'll find it useful. Thanks again - this site is always enlightening.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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