Date Diff based on criteria

happy_smiler1

New member
Joined
Aug 28, 2012
Messages
67
Reaction score
0
Points
0
Excel Version(s)
office 365
Hi All,

I wanted to be able to find the difference between two dates based on whether one criteria is the same as the criteria above it if so calculate the date difference between, if it doesnt then leave it and go to the next. Please find an example of my data set below:

e.g from my data set below - for customer id 1, row 4 would look up row 3 for customer id and because they match, it would calculate the date difference, same for row 3 to row 2, but row 2 doesnt have any data above it, it would automatically throw out a 0 against it.


A B C

Customer IDDateAmount
101/01/201220
102/01/201520
103/01/201635
312/12/201565
313/12/201812
523/01/20055
515/05/200714
1214/02/200413
1215/02/20068
1216/02/200916
1217/02/201219
1316/05/2013100
1317/05/2014120
1318/05/2015100


Any help would be greatly appreciated.

TIA
 
I'm not sure I understand 100% but try the DATEDIF function for the days calculation

Sent from my SM-G965F using Tapatalk
 
in D2 copied down:
=IF(A2=A1,DATEDIF(B1,B2,"d"),0)
?
 
'Doesn't work' isn't very informative.
In what way is the following wrong?:
2019-11-08_141641.jpg
 
I only get #NUM! if the dates are not ascending, your sample data doesn't produce such an error.
Sort the data primarily by ID, secondarily by date.
 
in D2 copied down:
=IF(A2=A1,DATEDIF(B1,B2,"d"),0)
?

Why would you use DATEDIF for days and not just subtract one from the other?

=IF(A2=A1,B2-B1,0)
 
Back
Top