Rate/Day over X Most Recent Entries

Bossi

New Member
Joined
Dec 28, 2010
Messages
10
Office Version
  1. 365
Platform
  1. Windows
My table's inputs include the date, the person for whom the data is for, and then various data values. Each of these values is cumulative & keeps climbing continuously upward. How can I add in a column that identifies the daily rate of change between the X most recent entries?

1729796726555.png


In the example above I use X = 3, so it's looking at the three most recent entries. The "Rate/Day over X Days" column is what I hope for the answer to be (assuming I didn't botch the manually-entered formulae for my example)

At its core I'm just trying to take "(GivenValue - ThirdRecentValue) / (GivenDate - ThirdRecentDate)", where Given refers to the date for that current row.

Of course the Given Date/Value are easy. But how can I find the Xth most recent date/value, where I'm finding the Xth entry before the given date?

I feel like there's an easy way to do this but I'm not yet figuring it out.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:

Book2
ABCDEF
1
2X = 3
3
4DateNameInputRate/Day over X Entries
52024.10.01Bossi1N/A
62024.10.01Joe1N/A
72024.10.02Bossi3N/A
82024.10.03Bossi62.5
92024.10.04Bossi103.5
102024.10.08Bossi192.6
112024.10.10Joe20N/A
122024.10.15Bossi402.7
132024.10.16Bossi453.3
142024.10.17Joe442.7
152024.10.20Bossi655.0
162024.10.21Bossi664.2
172024.10.22Bossi660.5
182024.10.22Joe502.5
192024.10.23Bossi681.0
202024.10.23Bossi7812.0
212024.10.23Joe653.5
22
Sheet3
Cell Formulas
RangeFormula
E5:E21E5=LET(x,$E$2,f,FILTER(B$5:D5,C$5:C5=C5),r,ROWS(f),IF(r<x,"N/A",(INDEX(f,r,3)-INDEX(f,r-x+1,3))/(INDEX(f,r,1)-INDEX(f,r-x+1,1))))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E5:E21Other TypeColor scaleNO
 
Upvote 1
Solution
Playing around with this I came up with a very marginally shorter version of Eric's formula in E5, copied down or a longer version in F5 but does not need to be copied down.

24 10 25.xlsm
ABCDEF
1
2X =3
3
4DateNameInputRate/Day over X EntriesRate/Day over X Entries
52024.10.01Bossi1N/AN/A
62024.10.01Joe1N/AN/A
72024.10.02Bossi3N/AN/A
82024.10.03Bossi62.52.5
92024.10.04Bossi103.53.5
102024.10.08Bossi192.62.6
112024.10.10Joe20N/AN/A
122024.10.15Bossi402.72.7
132024.10.16Bossi453.33.3
142024.10.17Joe442.72.7
152024.10.20Bossi655.05.0
162024.10.21Bossi664.24.2
172024.10.22Bossi660.50.5
182024.10.22Joe502.52.5
192024.10.23Bossi681.01.0
202024.10.23Bossi7812.012.0
212024.10.23Joe653.53.5
Rate per day
Cell Formulas
RangeFormula
F5:F21F5=BYROW(B5:D21,LAMBDA(r,LET(x,E2,c,INDEX(r,2),f,TAKE(FILTER(B$5:INDEX(r,3),C$5:c=c),-x),IFERROR((INDEX(f,x,3)-INDEX(f,1,3))/(INDEX(f,x,1)-INDEX(f,1,1)),"N/A"))))
E5:E21E5=LET(x,E$2,f,TAKE(FILTER(B$5:D5,C$5:C5=C5),-x),IFERROR((INDEX(f,x,3)-INDEX(f,1,3))/(INDEX(f,x,1)-INDEX(f,1,1)),"N/A"))
Dynamic array formulas.
 
Upvote 1
A bit shorter yet, but a bit more obscure:

Excel Formula:
=LET(x,$E$2,f,FILTER(B$5:D5,C$5:C5=C5),r,ROWS(f),a,r-{0,1}*(x-1),IF(r<x,"N/A",SLOPE(INDEX(f,a,3),INDEX(f,a,1))))
 
Upvote 1
EDIT - Solved my follow-up issue!

Thanks!! In trying to adapt this to my actual spreadsheet, however, I'm running into one issue that my example missed...

Let's say I have one more column in between the one I'm actually interested in... so now Column D is full of irrelevant data, and I'm trying to read out of what's now Column E?

Yet again I feel like there's probably just a small tweak to one of the formula above that I'm not yet finding.


1730172554569.png
 
Upvote 0
Ahh, nevermind - found what I needed to change! I suspected one of those numbers was a column modifier... just had to change a 3 to a 4. Solved! Thanks!!
 
Upvote 0
Ah, you just beat me! Glad you found the issue. For future reference, it's best to include all pertinent information in your question, including row and column headers, and any other columns. Ideally, try using the xl2bb tool to show your worksheet. That allows the helpers here to copy your data directly without having to retype everything. You'll likely get faster responses if you do.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top