unfortunately I can't provide a fully working example due to the lack of my laptop during my vacation :-)
What you're looking for can be achieved with the MDX functions AXIS and ITEM. Within this book
there is a dedicated chapter about "Context-Aware Calculations"
Hope this helps somehow
Tom