Rolling Percentage

I want to have a rolling percentage of a value across a series of values.

I want to be able to choose the value and the size of the series. Here is an example where I want to know the percentage of Oranges for the last 5 values.

Also, Is it possible to do a running percentage of the value? Just thought of that.

Ideally I would like to be able to have the card filterable, so it would be nice to have it as a beast mode or some way to be able to adjust depending on the filters.