• Have a look at "Time Intelligence" in Book online. It is a wizard that you can use (in BIDS/SSDT) to generate the MDX code for various time based calculations.