Average of active months

I have a module which shows asset values on a quarterly basis. For terminated products, the current asset values are nil.  However, instead of showing nil, I want to show the average asset value when in existence.  In my module there is a line item for product status and this can be active, liquidating, terminated but this may change on a quarterly basis.

Can someone please assist? I've been trying flags