SOLVED

Subtract a Date from the Previous Date in a Table Column Using Structural References

Copper Contributor

Is there a formula or function I can use to subtract one date from the previous date in the same column to get the number of days since the previous date?

 

I need to do this in a way that the formula doesn't crash when I delete a row in the middle, hence looking at structural references.  

 

I also need to make sure that the formula doesn't get an error when calculating the difference for the very first date in the column since it would try to subtract the column header from the first date.  The formula I have in column E takes care of the error catching, but not the deletion of rows.

 

Can someone help me with this?

 

Spreadsheet attached.

 

Thank you,

George

3 Replies
best response confirmed by George_Weston (Copper Contributor)
Solution

@George_Weston My Excel didn't like your file and could not open it. So, I created an example in a blank file as shown in the picture. Should work similar in your situation.

Screenshot 2021-03-19 at 08.34.10.png

@George_Weston 

That could be

=IF(ROW()=ROW(Table9[[#Headers],[Date]])+1, "",
    [@Date]-INDEX([Date],ROW()-ROW(Table9[[#Headers],[Date]])-1))
Thank you Riny. It is a simple elegant solution.
Regards,
George
1 best response

Accepted Solutions
best response confirmed by George_Weston (Copper Contributor)
Solution

@George_Weston My Excel didn't like your file and could not open it. So, I created an example in a blank file as shown in the picture. Should work similar in your situation.

Screenshot 2021-03-19 at 08.34.10.png

View solution in original post