Hi, yes, I think you will need some script help to precalculate, but before doing that, can you confirm you are calculateing the median?
For median you need to sort values and select the one in middle, if elements are even you will have 2 middle number and the value to return is tghe average between those two.
So for 2020 middle values for period 5 are 0,3373 and 0,368, and the average is 0,35265. And this value is not the one is shown on your example. How is this median calculated.
Anyway, I think you can do a sorted load of the values, spliting Year_month values in two fields, using order by to sort by month and year and using Peek() to access previous records. One field can count the accumulated records you have readed like: If(Year=Peek(Year), Peek(CountedRecords)+1, 1) as CountedRecords.
Use CountedRecords value to know if its Even or not and know how many records above you need to go with Peek() to retrieve the needed value.