Is it possible to do a calculation on filtered data? In this case filter the data by year and calculate the "No of Bookings made less than x days before check-in" where x = D4 e.g. 100

I'm using 365. Filter data by F6 (Check-In year). In C4 display the number of bookings made less than the value of D4

[![Example](https://i.stack.imgur.com/GbLAC.png)](https://i.stack.imgur.com/GbLAC.png)

I sort the data on F6 "Check-In year" these work.
In B2 I have `=SUBTOTAL(103,A7:A240)`
In F2 I have `=SUBTOTAL(109,D7:D240)/B2`

I've tried `=COUNTIF(D7:D240,"<10")` and `=SUBTOTAL(3,D7:D240)<10`, but my knowledge of SubTotal and Count if is limited I'm afraid. Hope someone might know.