Hi Peter,
I have just work through the same topic with @Craig_PaxsonTN in this Community post:
Get last n rows from a linked table.
The solution I propose in the document I share there makes use of a temp storage table, Craig has figured out a way to calculate without the temp table. I have asked him to share his solution.
If you are on a rush though, you can use what I shared in this doc:
R
P