count workers overlappings without counting duplicates - formula

Osvaldo Palmeiro

Well-known Member
Joined
Feb 24, 2009
Messages
752
Office Version
  1. 365
Platform
  1. Windows
Viaturas For Simult.xlsm
ABCDEF
1workersstart timeend timeexpected results unique workers in each intervalvisual check of expected results A2=worker A in row 2 B3=worker B in row 3 and so on ...
2A10:00:0020:20:006A2, B3, C4, F5, D6, E7
3B10:05:0010:45:005A2, B3, C4, F5, D6
4C10:10:0010:45:005A2, B3, C4, F5, D6
5F10:30:0011:00:006A2, B3, C4, F5, D6, E7
6D10:35:0011:25:006A2, B3, C4, F5, D6, E7
7E10:45:0013:00:006A2, F5, D6, E7, B8, C9
8B11:00:0011:30:004A2, D6, E7, B8
9C12:00:0014:00:005A2, E7, C9, F10, D11
10F12:30:0014:00:005A2, E7, C9, F10, D11
11D13:00:0013:10:004A2, C9, F10, D11
12E13:30:0015:00:004A2, C9, F10, E12
13F15:00:0018:00:005A2, F13, B14, C15, D16
14B15:50:0016:00:003A2, F13, B14as an example, highlighted
15C17:00:0017:15:003A2, F13, C15<<< this one to clarify
16D17:30:0018:00:003A2, F13, D16
17A21:05:0022:10:001A17
MrExcel


Hi all.
=SUM(--(FREQUENCY(IF((C$2:C$17>B2)*(C$2:C$17<C2),MATCH(A$2:A$17,A$2:A$17,0)),ROW(A$2:A$17)-1)>0))
I am using this formula with 4 variations at the IF condition in order to count overlapping of workers in column A, if they are simultaneously working accordingly to each hour interval in columns B and C (B=start time and C=end time of work).

Several workers enter and leave the working room several times during the day, so I am using the FREQUENCY() function to count overlapping of each worker only once in each interval.

The problem I am facing is some of overlappingS are being counted twice in some of these 4 variations, so I think if I could join the 4 conditions in just one formula it would work fine.

In plain expression, after adding one more condition to the formula above, I think it would be something like:
... FREQUENCY(OR(IF((C$2:C$17>B2)*(C$2:C$17<C2), IF((B$2:B$17>B2)*(B$2:B$17<C2), MATCH(...
I've tried some variations of this but with no success.

I don't know if this is possible. So, if it's possible and someone could please add the second OR condition like I showed in plain expression, then I think I'll be able to add the others two OR conditions.

If there is another way to do this job then I'm open and would appreciate.

Thanks so much for any help.
 

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,)
How about this?:

worker overlapping.xlsx
ABCDEF
1workersstart timeend timeexpected results unique workers in each intervalvisual check of expected results A2=worker A in row 2 B3=worker B in row 3 and so on ...Formula
2A10:00:0020:20:006A2, B3, C4, F5, D6, E76
3B10:05:0010:45:005A2, B3, C4, F5, D65
4C10:10:0010:45:005A2, B3, C4, F5, D65
5F10:30:0011:00:006A2, B3, C4, F5, D6, E76
6D10:35:0011:25:006A2, B3, C4, F5, D6, E76
7E10:45:0013:00:006A2, F5, D6, E7, B8, C96
8B11:00:0011:30:004A2, D6, E7, B84
9C12:00:0014:00:005A2, E7, C9, F10, D115
10F12:30:0014:00:005A2, E7, C9, F10, D115
11D13:00:0013:10:004A2, C9, F10, D114
12E13:30:0015:00:004A2, C9, F10, E124
13F15:00:0018:00:005A2, F13, B14, C15, D165
14B15:50:0016:00:003A2, F13, B143
15C17:00:0017:15:003A2, F13, C153
16D17:30:0018:00:003A2, F13, D163
17A21:05:0022:10:001A171
Hoja1
Cell Formulas
RangeFormula
F2:F17F2=SUM((UNIQUE(IFERROR(FILTER($A$2:$A$17,($A$2:$A$17<>A2)*($B$2:$B$17<C2)*($C$2:$C$17>B2)),""))<>"")*1)+1
 
Upvote 0
Hi, @felixstraube .
Thanks a lot, that works fine.

But, my fault, I forgot to say that the solution should be for XL 2013.
I know my profile says 365 version, but this file I'm working on is to be used for others in XL 2013.
I'm sorry for my fault.

Could you, please, think a solution for that version?

Many thanks again.
 
Upvote 0
How about this formula in F2 and drag down?:
I think you already know that it is an array formula and you have to enter it with Ctrl+Shift+Enter.

Excel Formula:
=SUM((FREQUENCY(IFERROR(XMATCH(IF((A2<>$A$2:$A$17)*(B2<$C$2:$C$17)*(C2>$B$2:$B$17),$A$2:$A$17,""),$A$2:$A$17,0),""),IFERROR(XMATCH(IF((A2<>$A$2:$A$17)*(B2<$C$2:$C$17)*(C2>$B$2:$B$17),$A$2:$A$17,""),$A$2:$A$17,0),""))>0)*1)+1
 
Upvote 0
Hi, @felixstraube.

Thank you very very much.

I changed XMATCH(() to MATCH() and it seems to work nicely for all start/end time variations, including in XL 2013.

It's a Xmas gift. :)

Thanks again.
 
Upvote 0
Sure, sorry i forgot XMATCH is one of the new functions. Happy to help. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,097
Latest member
mlckr

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