JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,676
- Office Version
- 365
- Platform
- Windows
The minisheet below is my attempt to calculate the number of events (not the number of days) that have occurred since the last time that event occurred.
Col B has the events. Col C has the dates when they have occurred. Cols D & E are parts of the solution. D is the row # of this event. E is the row # of the previous occurrence of that event. Col F puts these together and adds IfError. Is there a better way?
Note: This depends on the table being sorted by date (newest to oldest).
Col B has the events. Col C has the dates when they have occurred. Cols D & E are parts of the solution. D is the row # of this event. E is the row # of the previous occurrence of that event. Col F puts these together and adds IfError. Is there a better way?
Note: This depends on the table being sorted by date (newest to oldest).
Take Function.xlsx | ||||||||
---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | |||
3 | Event | Date | Row # | Row #(Next) | # Events | Comments | ||
4 | A | 6/10/24 | 1 | 4 | 4 | Event A last occurred 4 events ago. | ||
5 | B | 6/08/24 | 2 | 2 | 2 | Event B last occurred 2 events ago. | ||
6 | C | 6/05/24 | 3 | 3 | 3 | Event C last occurred 3 events ago. | ||
7 | B | 6/02/24 | 4 | 5 | 5 | Event B last occurred 5 events ago. | ||
8 | A | 5/30/24 | 5 | #N/A | n/a | This is the first time event A occurred. | ||
9 | C | 5/25/24 | 6 | #N/A | n/a | This is the first time event C occurred. | ||
10 | D | 5/20/24 | 7 | 1 | 1 | Event D last occurred 1 event ago. | ||
11 | D | 5/19/24 | 8 | #N/A | n/a | This is the first time event D occurred. | ||
12 | B | 5/10/24 | 9 | #N/A | n/a | This is the first time event B occurred. | ||
Count Between |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D4:D12 | D4 | =ROW()-ROW(Table4[[#Headers],[Event]]) |
E4:E12 | E4 | =MATCH([@Event],DROP([Event],[@[Row '#]]),0) |
F4:F12 | F4 | =IFERROR(MATCH([@Event],DROP([Event],ROW()-ROW(Table4[[#Headers],[Event]])),0),"n/a") |