Consecutive Dates for Unique ID's

spaceflea

New Member
Joined
Feb 26, 2018
Messages
7
Hey guys, I was wondering how would go about doing this:

I have a data set of unique ID's and two date columns.

Ex.

[TABLE="width: 271"]
<tbody>[TR]
[TD]Unique ID[/TD]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1/10/2000[/TD]
[TD="align: right"]1/15/2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1/16/2000[/TD]
[TD="align: right"]1/20/2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1/21/2000[/TD]
[TD="align: right"]1/23/2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]2/1/2000[/TD]
[TD="align: right"]2/4/2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]2/5/2000[/TD]
[TD="align: right"]2/8/2000[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2/2/2000[/TD]
[TD="align: right"]2/7/2000[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2/8/2000[/TD]
[TD="align: right"]2/12/2000[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]3/1/2000[/TD]
[TD="align: right"]3/3/2000[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]3/4/2000[/TD]
[TD="align: right"]3/7/2000[/TD]
[/TR]
</tbody><colgroup><col><col><col></colgroup>[/TABLE]


How would I be able to only select the EARLIEST consecutive dates for each unique ID's. Ideally, after the filtering, the data set would look like this:

[TABLE="width: 271"]
<tbody>[TR]
[TD]Unique ID[/TD]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1/10/2000[/TD]
[TD="align: right"]1/15/2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1/16/2000[/TD]
[TD="align: right"]1/20/2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1/21/2000[/TD]
[TD="align: right"]1/23/2000[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2/2/2000[/TD]
[TD="align: right"]2/7/2000[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2/8/2000[/TD]
[TD="align: right"]2/12/2000[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]3/4/2000[/TD]
[TD="align: right"]3/7/2000[/TD]
[/TR]
</tbody><colgroup><col><col><col></colgroup>[/TABLE]


What's really throwing me off is that third column of end date. I've reference a few posts on this site where you can filter out entries based on consecutive dates, but in the examples the dates have always been individually present and never in a span across two columns.

Thank you in advance!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
In a separate column (I've used column D), enter the following:
=OR(A2<>A1,AND(A2=A1,B2-1=C1,D1<>FALSE))
 
Upvote 0
In a separate column (I've used column D), enter the following:
=OR(A2<>A1,AND(A2=A1,B2-1=C1,D1<>FALSE))


Thank you so much for the reply!

For some reason I'm just getting a column of zeros in column D. I had to change the formatting of the function from the one you provided to:
=OR(A3<>A2$ AND(A3=A2$ B3-1=C2$ D2<>FALSE))

Excel wasn't differentiating after the commas.

Any ideas what I could be doing wrong?
 
Upvote 0
Thank you so much for the reply!

For some reason I'm just getting a column of zeros in column D. I had to change the formatting of the function from the one you provided to:
=OR(A3<>A2$ AND(A3=A2$ B3-1=C2$ D2<>FALSE))

Excel wasn't differentiating after the commas.

Any ideas what I could be doing wrong?

Edit*

=OR(A2<>A1$ AND(A2=A1$ B2-1=C1$ D1<>FALSE))
 
Upvote 0

Forum statistics

Threads
1,223,979
Messages
6,175,757
Members
452,667
Latest member
vanessavalentino83

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