How to do roll-up on the last 10 rows

Is there any way to sum or average other table’s last 10 rows not the entire rows?
I can have a roll-up column to calculate average or sum of the entire rows but can’t find ways to do on specific rows.

Do you have this data in the Sheets or Glide Tables? I think we would need an incremental “row number” here to do this.

Always appreciate your help.
The rows are in the sheet and I have another Glide table for roll-up. What’s the next step if I have an incremental row number in the sheet?

Yeah assume you have an incremental row number like 1, 2, 3, etc.

Create a rollup in the same sheet and get the max number in that incremental column.

Create a math column, let’s call it “Last 10 limit”. The formula would be:

Max - 9 with Max being the number from the max rollup.

Next, an If Then Else column. If row number greater than or equal to “Last 10 limit” then return the desired value you want to rollup originally, else 0 or empty.

Finally, rollup on the ITE column.