Ok, I just realised you are using an array formula - I rarely do myself so didn't realise at first esp since the requirement seems odd.
Your problem is that Mid() returns a string not a value. Force Excel to consider the result as a number. E.g. try:
=median([r]--[/r]mid(am1:am3,3,2))
Entered as an Array formula using CTRL+SHIFT+ENTER
Gavin