Excel Formula for average differences between different rows for the same ID

kenderweasel

New Member
Joined
Feb 17, 2017
Messages
40
Hi,

I have a spreadsheet which lists a customer ID, Chat Start Time, Chat End Time, and Date. I need a formula that will look up the chat end time of the first interaction with a particular customer ID, then work out the time difference between that and the chat start time of the next interaction with the same customer, and so on - resulting in a single figure for that customer that gives the average difference between the individual chats. I then need to return an average time between chats for all customers with a particular number of interactions on a particular date. I think I need an array formula, but I don't know where to start :(

[TABLE="width: 304"]
<colgroup><col width="127" style="width: 95pt; mso-width-source: userset; mso-width-alt: 4644;" span="2"> <col width="77" style="width: 58pt; mso-width-source: userset; mso-width-alt: 2816;"> <col width="75" style="width: 56pt; mso-width-source: userset; mso-width-alt: 2742;"> <tbody>[TR]
[TD="width: 127, bgcolor: transparent, align: left"]Customer ID[/TD]
[TD="width: 127, bgcolor: transparent, align: left"]Date[/TD]
[TD="width: 77, bgcolor: transparent, align: left"]Chat Start[/TD]
[TD="width: 75, bgcolor: transparent, align: left"]Chat End[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]7[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]12:04[/TD]
[TD="bgcolor: transparent, align: right"]12:16[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]432[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]15:08[/TD]
[TD="bgcolor: transparent, align: right"]15:12[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]46[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]02:19[/TD]
[TD="bgcolor: transparent, align: right"]03:21[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]07:56[/TD]
[TD="bgcolor: transparent, align: right"]08:05[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]7[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]16:54[/TD]
[TD="bgcolor: transparent, align: right"]17:05[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]7[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]13:04[/TD]
[TD="bgcolor: transparent, align: right"]13:22[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]432[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]11:17[/TD]
[TD="bgcolor: transparent, align: right"]12:05[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]46[/TD]
[TD="bgcolor: transparent, align: right"]28/08/2018[/TD]
[TD="bgcolor: transparent, align: right"]09:15[/TD]
[TD="bgcolor: transparent, align: right"]09:32[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Can you use these? Note all the time values have been formatted as [h]:mm in Custom Formats;


Book1
ABCDE
1Customer IDDateChat StartChat End
24628-08-182:193:21
3328-08-187:568:05
44628-08-189:159:32
543228-08-1811:1712:05
6728-08-1812:0412:16
7728-08-1813:0413:22
843228-08-1815:0815:12
9728-08-1816:5417:05
10
11Customer IDAVG
1272:10
13
14Customer IDChat StartChat EndDIFFERENCE
15712:0412:160:48
16713:0413:223:32
17716:5417:05
18
19ALL CHATS0:22
20
21DateCustomer IDChat StartChat EndDIFFERENCE
2228-08-18462:193:211:02
2337:568:050:09
24469:159:320:17
2543211:1712:050:48
26712:0412:160:12
27713:0413:220:18
2843215:0815:120:04
29716:5417:050:11
Sheet1
Cell Formulas
RangeFormula
B12=AVERAGEIF($D$15:$D$17,"<>0")
B19=AVERAGEIF($E$22:$E$29,"<>0")
B15{=IFERROR(INDEX(C$2:C$9,SMALL(IF($A$2:$A$9=$A$12,ROW($A$2:$A$9)-ROW($A$2)+1),ROWS(A$15:A15))),"")}
B22{=IFERROR(INDEX($A$2:$A$9,SMALL(IF($B$2:$B$9=$A$22,ROW($B$2:$B$9)-ROW($B$2)+1),ROWS($B$22:B22))),"")}
D15=IFERROR(B16-C15,"")
D22{=IFERROR(INDEX($D$2:$D$9,SMALL(IF($B$2:$B$9=$A$22,ROW($B$2:$B$9)-ROW($B$2)+1),ROWS($B$22:B22))),"")}
E22=IFERROR(D22-C22,"")
A15{=IFERROR(INDEX($A$2:$A$9,SMALL(IF($A$2:$A$9=$A$12,ROW($A$2:$A$9)-ROW($A$2)+1),ROWS(A$15:A15))),"")}
C15{=IFERROR(INDEX(D$2:D$9,SMALL(IF($A$2:$A$9=$A$12,ROW($A$2:$A$9)-ROW($A$2)+1),ROWS(B$15:B15))),"")}
C22{=IFERROR(INDEX($C$2:$C$9,SMALL(IF($B$2:$B$9=$A$22,ROW($B$2:$B$9)-ROW($B$2)+1),ROWS($B$22:B22))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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