I wanted to select difference between two date dimensions in MDX, where value of a KPI measure is not empty, after some tries I could figure out the query as seen below:
WITH
MEMBER[Measures].[dif] as Datediff("d",[Delivery Date].[Date].currentmember.MEMBERVALUE,[Ship Date].[Date].currentmember.MEMBERVALUE)
SELECT NON EMPTY { [Measures].[dif], KPIValue("Product Gross Profit Margin") } ON COLUMNS, { NonEmpty
([Delivery
Date].[Date].[Date].ALLMEMBERS * [Ship Date].[Date].[Date].ALLMEMBERS, KPIValue("Product Gross Profit Margin") ) }
ON ROWS FROM [Adventure Works]