There's a demo from "MDX Step by Step 2008", it introduce the usage of 'EXISTING' to provide the context for set in calculated member.
WITH MEMBER [Measures].[Number of Products] AS COUNT( [Product].[Product].[Product].Members ) SELECT { ([Measures].[Reseller Sales Amount]), ([Measures].[Number of Products]) } ON COLUMNS, {[Product].[Category].Members} ON ROWS FROM [Step-by-Step] GO WITH MEMBER [Measures].[Number of Products] AS COUNT( EXISTING [Product].[Product].[Product].Members ) SELECT { ([Measures].[Reseller Sales Amount]), ([Measures].[Number of Products]) } ON COLUMNS, {[Product].[Category].Members} ON ROWS FROM [Step-by-Step]
Two outputs - the second output is correct.
Now I try another demo to get the last date with data, but I found there's no any difference when using 'EXISTING' or not.
WITH MEMBER [Measures].[Last Date] AS MAX({[Date].[Date].[Date].MEMBERS}, IIF( ([Measures].[Internet Order Count]) = 0, NULL, [Date].[Date].CurrentMember.MemberValue ) ) SELECT {[Measures].[Internet Order Count],[Measures].[Last Date]} ON 0, {[Promotion].[Promotion].MEMBERS} ON 1 FROM [Adventure Works] GO WITH MEMBER [Measures].[Last Date] AS MAX(EXISTING{[Date].[Date].[Date].MEMBERS}, IIF( ([Measures].[Internet Order Count]) = 0, NULL, [Date].[Date].CurrentMember.MemberValue ) ) SELECT {[Measures].[Internet Order Count],[Measures].[Last Date]} ON 0, {[Promotion].[Promotion].MEMBERS} ON 1 FROM [Adventure Works]
The outputs are same.
My expected result for last date in first query which don't have 'EXISTING' should be always 7/31/2008, because there's no context for Date member, so it always return the MAX date with data.
MAX({[Date].[Date].[Date].MEMBERS}, IIF( ([Measures].[Internet Order Count]) = 0, NULL, [Date].[Date].CurrentMember.MemberValue ) )Anyone could help to explain why I got the same output when using EXISTING or not?
Thanks!
Please vote if it's helpful and mark it as an answer!