By the way, could you also shed some light on how the median calculation might be done? Can you even put conditions on median calculation in much the same way as the AVERAGE()?

Thanks