I have started working on MDX queries also. Basic syntax looks like SQL queries but still it is far different than SQL queries. While working I found some difficulties to apply some tricky logic in queries, so I thought to jot down the tricks for others will helpful for some one. So I am hopping that you should know the basic logic to write MDX queries and below are some defined situation and its logic. Checking which hierarchy is selected on Axis: CASE when NOT IsError(Extract( Axis (0), [Dim Date].[Calendar_Year]). Count ) then (Formula for Calendar year hierarchy ) when NOT IsError(Extract( Axis (1), [Dim Date].[Calendar_Year]). Count ) then ( Formula for Calendar year hierarchy ) when NOT IsError(Extract( Axis (0), [Dim Date].[Fiscal_Year]). Count ) then ( Formula for Fiscal hierarchy ) when NOT IsError(Extract( Axis (1), [Dim Date].[Fiscal_Year]). Count ) then ( Formula for Fiscal hierarchy ) else '-1' END H...