Subindexing and Marginal Differencing

dfdsiii

New Member
Joined
Sep 10, 2019
Messages
1
I have this dataset:
[TABLE="width: 682"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]Time[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]8:00 AM[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]10:00 AM[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]4:00 PM[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]5:00 PM[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/2/2019[/TD]
[TD]8:00 AM[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/2/2019[/TD]
[TD]5:00 PM[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]9:00 AM[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]3:00 PM[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]5:00 PM[/TD]
[/TR]
</tbody>[/TABLE]
The first thing I want to do is add a subindex on User and Date.
[TABLE="width: 682"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]Time[/TD]
[TD]User/Date Index[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]8:00 AM[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]10:00 AM[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]4:00 PM[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]5:00 PM[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/2/2019[/TD]
[TD]8:00 AM[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/2/2019[/TD]
[TD]5:00 PM[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]9:00 AM[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]3:00 PM[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]5:00 PM[/TD]
[TD]3[/TD]
[/TR]
</tbody>[/TABLE]
The second thing I want is a column that takes the difference between times in its row (A) and the row after it (A+1). "n/a" means I don't really care about this value. I just want the interday marginal differences.
[TABLE="width: 682"]
<tbody>[TR]
[TD]User[/TD]
[TD]Date[/TD]
[TD]Time[/TD]
[TD]User/Date Index[/TD]
[TD]Marginal Difference[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]8:00 AM[/TD]
[TD]1[/TD]
[TD]02:00:00[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]10:00 AM[/TD]
[TD]2[/TD]
[TD]06:00:00[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]4:00 PM[/TD]
[TD]3[/TD]
[TD]01:00:00[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/1/2019[/TD]
[TD]5:00 PM[/TD]
[TD]4[/TD]
[TD]n/a[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/2/2019[/TD]
[TD]8:00 AM[/TD]
[TD]1[/TD]
[TD]09:00:00[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]9/2/2019[/TD]
[TD]5:00 PM[/TD]
[TD]2[/TD]
[TD]n/a[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]9:00 AM[/TD]
[TD]1[/TD]
[TD]06:00:00[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]3:00 PM[/TD]
[TD]2[/TD]
[TD]02:00:00[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]9/1/2019[/TD]
[TD]5:00 PM[/TD]
[TD]3[/TD]
[TD]n/a[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi & welcome to MrExcel.
How about


Book1
ABCDE
1UserDateTime
2A09/01/20198:00 AM102:00:00
3A09/01/201910:00 AM206:00:00
4A09/01/20194:00 PM301:00:00
5A09/01/20195:00 PM4
6A09/02/20198:00 AM109:00:00
7A09/02/20195:00 PM2
8B09/01/20199:00 AM106:00:00
9B09/01/20193:00 PM202:00:00
10B09/01/20195:00 PM3
Data
Cell Formulas
RangeFormula
D2=COUNTIFS(A$2:A2,A2,B$2:B2,B2)
E2=IF(D3>D2,C3-C2,"")
 
Upvote 0

Forum statistics

Threads
1,224,745
Messages
6,180,700
Members
452,994
Latest member
Janick

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