My dataset looks like below
| ID | Date 1 | Date 2 |
|---|---|---|
| A | 01Aug2020 | . |
| A | 01Sep2020 | . |
| A | 01Oct2020 | . |
| A | 01Dec2020 | . |
| A | . | 01Nov2020 |
| A | . | 01Jan2021 |
| B | 01Mar2020 | . |
| B | 01Apr2020 | . |
| B | . | 01Jan2020 |
| C | 01Jan2020 | . |
| C | 01Mar2020 | . |
| C | . | 01Feb2020 |
| D | 01Jan2020 | . |
| D | 01Feb2020 | . |
| D | . | 01Mar2020 |
There is never any crossover dates between dates 1 and 2, and whenever one field is populated the other is null.
I want to filter the table into different categories for each ID. The most important one is where Date2 is between some of the dates in the Date1 field (so between the min and max of Date1).
So this filters the table to ID A 01Nov2020 as this is between the min for ID A (01Aug2020) and max (01Dec2020). As well as ID C 01Feb2020, as this is between the min for ID C (01Jan2020) and max (01Mar2020).
Less importantly I then want to filter the table where date2 comes before the minimum of Date1 (for example ID B 01Jan2020). And then a final filtered table where date2 comes before the minimum of Date1 (for example ID D 01Mar2020 as well as ID A 01Jan2021).
The difficult part is that they are not aligned up in rows so have to work across multiple rows in the dataset. I believe I may need to use the Array function but I am not sure. Any help would be greatly appreciated.