Yes it can be done. In the past for such requirement I created was using a UD8 dimension as a reporting dimension. In this dimension, I would create a dynamic calc collection of members for various purpose like this one. I don't have the formula in front of me, bu I was testing wether the dimensions were base level or not. If base level, just take the value for the standard UD8 member where data is stored ("None" in my case), but if the members of a specific dimension had children, then I would "collect" them in a data buffer, and play with the value I collected from there, like calculate an average or a median value.
Does it make sense ?