SOLVED

Complex Date and Address Problem

Copper Contributor

Hi All,

 

I have a situation that I cannot solve and need to produce a formula for. The situation is the following. I have a table with a unique person ID and then their past and current addresses. These addresses have a From and To Date. I then have a form which was completed at a certain date and want to find at which address the person was living when that form was completed. Now this would be easy if we did not have data quality issues. Often the To Date is missing so we need to then compare the two from dates to find out at which address the form was completed.

E.g

 IDAddressFromTo
555103/04/2017 
555210/11/2016 
555303/05/201610/11/2016
    
    
Form Done15/02/2017  

 

In this example the address the form was completed at was address 2. 

 

Anyone have any ideas? 

 

3 Replies

How about adding an extra 'Best guess' column that you can check against if the To column is empty.

 

This would work I think: - entered as an array (ctrl+shift+enter)

=IF(ISBLANK(D2),IFERROR(INDEX($C$2:$C$7,MATCH((B2 - 1) & A2,$B$2:$B$7 & $A$2:$A$7,0)),TODAY()),"")

Ends up looking like this:

 IDAddressFromToBest Guest
555103/04/2017 14/8/18
555210/11/2016 3/4/17
555303/05/201610/11/2016 
 4445/8/16 14/6/18
44423/7/164/8/16 
 44434/6/16 3/7/16
Form Done15/02/2017   

(14/08/16 in this case would be todays date)

best response confirmed by Jay Virdee (Copper Contributor)
Solution

Dear Jay Virdee,

Kindly refer to the formulas below for

 

1. Finding the Address on the particular Date. (Cell H2, coloured Green)

=INDEX($B$1:$B$10000,MATCH(F2&" "&MAX(IF($C$1:$C$10000<=$G2,$C$1:$C$10000,0)*IF($A$1:$A$10000=$F2,1,0)),$A$1:$A$10000&" "&$C$1:$C$10000,0),1)

 

2. Finding the 'TO' Date. (Cell H2, coloured Yellow)

=MIN(IFERROR(IF($C$2:$C$100>C2,$C$2:$C$100,"-")*IF($A$2:$A$100=A2,1,"-")-1,TODAY()))

 

Notes:

1. The formulas work correctly even when the dates are not sorted.

2. Both the formulas are Array Formulas. They need to be entered using Control + Shift + Enter, instead of Enter.

3. Change the cell references as required. Refer to the attached photograph.

4. To find the address on a particular Date, I have not used the 'To' Date. All dates till the next change of address for the particular ID have been considered to be at the previous address.

5. For the last entry of date for each ID, Today() has been used.

 

Vijaykumar Shetye,

Spreadsheet Excellence,

Panaji, Goa, India

VijaykumarShetye.png

 

 

Thanks this works really well.
1 best response

Accepted Solutions
best response confirmed by Jay Virdee (Copper Contributor)
Solution

Dear Jay Virdee,

Kindly refer to the formulas below for

 

1. Finding the Address on the particular Date. (Cell H2, coloured Green)

=INDEX($B$1:$B$10000,MATCH(F2&" "&MAX(IF($C$1:$C$10000<=$G2,$C$1:$C$10000,0)*IF($A$1:$A$10000=$F2,1,0)),$A$1:$A$10000&" "&$C$1:$C$10000,0),1)

 

2. Finding the 'TO' Date. (Cell H2, coloured Yellow)

=MIN(IFERROR(IF($C$2:$C$100>C2,$C$2:$C$100,"-")*IF($A$2:$A$100=A2,1,"-")-1,TODAY()))

 

Notes:

1. The formulas work correctly even when the dates are not sorted.

2. Both the formulas are Array Formulas. They need to be entered using Control + Shift + Enter, instead of Enter.

3. Change the cell references as required. Refer to the attached photograph.

4. To find the address on a particular Date, I have not used the 'To' Date. All dates till the next change of address for the particular ID have been considered to be at the previous address.

5. For the last entry of date for each ID, Today() has been used.

 

Vijaykumar Shetye,

Spreadsheet Excellence,

Panaji, Goa, India

VijaykumarShetye.png

 

 

View solution in original post