Home
%3CLINGO-SUB%20id%3D%22lingo-sub-370370%22%20slang%3D%22en-US%22%3EMDX%3A%20SET%20overwrite%20and%20the%20use%20of%20EXISTING%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-370370%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Feb%2011%2C%202013%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20SET%20overwrite%20is%20largely%20impacted%20by%20the%20attribute%20relationships%20and%20the%20behavior%20does%20depend%20on%20whether%20the%20attribute%20is%20below%20or%20above%20or%20no%20relationship%20in%20the%20relationship%20chains.%3C%2FP%3E%0A%3CP%3EFor%20illustrate%20the%20point%2C%20I%20run%20a%20test%20base%20on%20the%20following%20test%20environment%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESQL%20Server%202012%20Analysis%20Services%20Multidimensional%20Model%3C%2FLI%3E%0A%3CLI%3EDatabase%3A%20AdventureWorksDW2012Multidimensional-EE%20(%20%3CA%20href%3D%22http%3A%2F%2Fmsftdbprodsamples.codeplex.com%2Freleases%2Fview%2F55330%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Adventure%20Works%20for%20SQL%20Server%202012%20%3C%2FA%3E%20).%3C%2FLI%3E%0A%3CLI%3EStorage%20Mode%3A%20MOLAP%3C%2FLI%3E%0A%3CLI%3ERef%3A%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms145541.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20EXISTING%20Keyword%20(MDX)%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%20Case%201%3A%26nbsp%3B%20The%20SET%20is%20in%20%5BCity%5D%20level.%20The%20slicer%20is%20in%20%5BState-Province%5D%20level.%20%5BState-Province%5D%20is%201%20to%20many%20to%20%5BCity%5D.%20%5BCity%5D%20is%20in%20the%20below%20the%20relationship%20chain.%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EHere%20is%20the%20example%20query%3C%2FP%3E%0A%3CPRE%3E%0AWITH%0A%20%20MEMBER%20%5Bcustomer%5D.%5Bcity%5D.a%20AS%0A%20%20%20%20Aggregate%0A%20%20%20%20(%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BRedwood%20City%5D%26amp%3B%5BCA%5D%0A%20%20%20%20%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSpokane%5D%26amp%3B%5BWA%5D%0A%20%20%20%20%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSeattle%5D%26amp%3B%5BWA%5D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20)%0ASELECT%0A%20%20%5BMeasures%5D.%5BInternet%20Sales%20Amount%5D%20ON%200%0A%20%2C%7B%0A%20%20%20%20%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BRedwood%20City%5D%26amp%3B%5BCA%5D%0A%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSpokane%5D%26amp%3B%5BWA%5D%0A%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSeattle%5D%26amp%3B%5BWA%5D%0A%20%20%20%2C%5Bcustomer%5D.%5Bcity%5D.a%0A%20%20%7D%20ON%201%0AFROM%20%5BAdventure%20Works%5D%0AWHERE%0A%20%20(%0A%20%20%20%20%5BDate%5D.%5BCalendar%5D.%5BMonth%5D.%26amp%3B%5B2008%5D%26amp%3B%5B4%5D%0A%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BWA%5D%26amp%3B%5BUS%5D%0A%20%20)%3B%20%0A%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3E%20Scenario%201%3A%20Attribute%20Relationship%20is%20defined%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIf%20we%20keep%20the%20existing%20attribute%20relationship%20defined%20between%20%5BCity%5D%20and%20%5BState-Province%5D%20in%20the%20sample%20%5BAdventureWorksDW2012Multidimensional-EE%5D%20database%2C%20we%20get%20the%20following%20result%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3EInternet%20Sales%20Amount%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3ESpokane%3C%2FP%3E%0A%20%20%3CP%3ESeattle%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%246%2C275.72%3C%2FP%3E%0A%20%20%3CP%3E%243%2C527.85%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%3CMARK%3Ea%3C%2FMARK%3E%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%3CMARK%3E%2418%2C890.50%3C%2FMARK%3E%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3EThe%20SET%20ignores%20the%20slicer%20in%20WHERE%20clause.%20The%20value%20of%20%22a%22%20includes%20the%20value%20from%20Redwood%20City%2C%20CA%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Scenario%202%3A%20Attribute%20Relationship%20is%20NOT%20defined%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIf%20we%20remove%20the%20attribute%20relationship%20between%20%5BCity%5D%20and%20%5BState-Province%5D%20from%20the%20dimension%2C%20the%20concept%20of%20%E2%80%9Cauto%20exist%E2%80%9D%20kicks%20in.%20The%20aggregation%20value%20of%20a%20does%20not%20include%20Redwood%20City%2C%20CA%20anymore.%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3EInternet%20Sales%20Amount%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3ESpokane%3C%2FP%3E%0A%20%20%3CP%3ESeattle%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%246%2C275.72%3C%2FP%3E%0A%20%20%3CP%3E%243%2C527.85%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%3CMARK%3Ea%3C%2FMARK%3E%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%3CMARK%3E%249%2C803.57%3C%2FMARK%3E%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3EThe%20slicer%20in%20the%20WHERE%20clause%20overwrites%20the%20SET.%20The%20value%20of%20%22a%22%20does%20not%20includes%20Redwood%20City%2C%20CA%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20The%20use%20of%20existing%20function%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Scenario%203%3A%20Attribute%20Relationship%20is%20defined%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CPRE%3E%0AWITH%0A%20%20MEMBER%20%5Bcustomer%5D.%5Bcity%5D.a%20AS%0A%20%20%20%20Aggregate%0A%20%20%20%20(%0A%20%20%20%20%20%20(EXISTING%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BRedwood%20City%5D%26amp%3B%5BCA%5D%0A%20%20%20%20%20%20%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSpokane%5D%26amp%3B%5BWA%5D%0A%20%20%20%20%20%20%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSeattle%5D%26amp%3B%5BWA%5D%0A%20%20%20%20%20%20%20%20%7D)%0A%20%20%20%20)%0ASELECT%0A%20%20%5BMeasures%5D.%5BInternet%20Sales%20Amount%5D%20ON%200%0A%20%2C%7B%0A%20%20%20%20%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BRedwood%20City%5D%26amp%3B%5BCA%5D%0A%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSpokane%5D%26amp%3B%5BWA%5D%0A%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSeattle%5D%26amp%3B%5BWA%5D%0A%20%20%20%2C%5Bcustomer%5D.%5Bcity%5D.a%0A%20%20%7D%20ON%201%0AFROM%20%5BAdventure%20Works%5D%0AWHERE%0A%20%20(%0A%20%20%20%20%5BDate%5D.%5BCalendar%5D.%5BMonth%5D.%26amp%3B%5B2008%5D%26amp%3B%5B4%5D%0A%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BWA%5D%26amp%3B%5BUS%5D%0A%20%20)%3B%20%0A%3C%2FPRE%3E%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3EInternet%20Sales%20Amount%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3ESpokane%3C%2FP%3E%0A%20%20%3CP%3ESeattle%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%246%2C275.72%3C%2FP%3E%0A%20%20%3CP%3E%243%2C527.85%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3Ea%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%249%2C803.57%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%3CP%3EWith%20EXISTING%20function%2C%20the%20Slicer%20in%20the%20WHERE%20clause%20overwrites%20the%20SET%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Scenario%204%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20EXISTING%20function%20has%20no%20impact%20on%20the%20result%20if%20no%20attribute%20relationships%20are%20defined.%3C%2FP%3E%0A%3CP%3EYou%20get%20the%20same%20result%20just%20as%20without%20using%20the%20Existing%20function%3C%2FP%3E%0A%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3EInternet%20Sales%20Amount%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3ESpokane%3C%2FP%3E%0A%20%20%3CP%3ESeattle%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%246%2C275.72%3C%2FP%3E%0A%20%20%3CP%3E%243%2C527.85%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3E%0A%20%20%3CP%3Ea%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3E%249%2C803.57%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%0A%3CP%3E%3CSTRONG%3E%20Case%202%3A%20The%20SET%20is%20in%20%5BState-Province%5D%20level.%20The%20slicer%20is%20in%20%5BCity%5D%20level.%20%5BState-Province%5D%20is%201%20to%20many%20to%20%5BCity%5D.%20%5BState-Province%5D%20is%20in%20the%20above%20the%20relationship%20chain.%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%0A%3CPRE%3E%0AWITH%0A%20%20MEMBER%20%5BCustomer%5D.%5BState-Province%5D.%5Ba%5D%20AS%0A%20%20%20%20Aggregate%0A%20%20%20%20(%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BCA%5D%26amp%3B%5BUS%5D%0A%20%20%20%20%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BWA%5D%26amp%3B%5BUS%5D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20)%0ASELECT%0A%20%20%5BMeasures%5D.%5BInternet%20Sales%20Amount%5D%20ON%200%0A%20%2C%7B%0A%20%20%20%20%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BCA%5D%26amp%3B%5BUS%5D%0A%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BWA%5D%26amp%3B%5BUS%5D%0A%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%5Ba%5D%0A%20%20%7D%20ON%201%0AFROM%20%5BAdventure%20Works%5D%0AWHERE%0A%20%20(%0A%20%20%20%20%5BDate%5D.%5BCalendar%5D.%5BMonth%5D.%26amp%3B%5B2008%5D%26amp%3B%5B4%5D%0A%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSeattle%5D%26amp%3B%5BWA%5D%0A%20%20)%3B%20%0A%3C%2FPRE%3E%0A%0A%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3EInternet%20Sales%20Amount%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3EWashington%3C%2FTD%3E%0A%20%3CTD%3E%243%2C527.85%3C%2FTD%3E%0A%20%3CTD%3EIt%20contains%20the%20value%20for%20Seattle%20only%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3Ea%3C%2FTD%3E%0A%20%3CTD%3E%24462%2C840.69%3C%2FTD%3E%0A%20%3CTD%3E%20'a'%20shows%20the%20value%20for%20Washington%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%3CP%3E%3CSTRONG%3E%20Scenario%206%20%E2%80%93%20Attribute%20relationship%20is%20NOT%20defined%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3EInternet%20Sales%20Amount%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3EWashington%3C%2FTD%3E%0A%20%3CTD%3E%243%2C527.85%3C%2FTD%3E%0A%20%3CTD%3ESeattle's%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3Ea%3C%2FTD%3E%0A%20%3CTD%3E%243%2C527.85%3C%2FTD%3E%0A%20%3CTD%3EThe%20slicer%20overwrites%20the%20SET%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%3CP%3E%3CSTRONG%3E%20Adding%20EXISTING%20function%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CPRE%3E%0AWITH%0A%20%20MEMBER%20%5BCustomer%5D.%5BState-Province%5D.%5Ba%5D%20AS%0A%20%20%20%20Aggregate%0A%20%20%20%20(%0A%20%20%20%20%20%20(%3CMARK%3EEXISTING%3C%2FMARK%3E%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BCA%5D%26amp%3B%5BUS%5D%0A%20%20%20%20%20%20%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BWA%5D%26amp%3B%5BUS%5D%0A%20%20%20%20%20%20%20%20%7D)%0A%20%20%20%20)%0ASELECT%0A%20%20%5BMeasures%5D.%5BInternet%20Sales%20Amount%5D%20ON%200%0A%2C%7B%0A%20%20%20%20%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BCA%5D%26amp%3B%5BUS%5D%0A%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%26amp%3B%5BWA%5D%26amp%3B%5BUS%5D%0A%20%20%20%2C%5BCustomer%5D.%5BState-Province%5D.%5Ba%5D%0A%20%20%7D%20ON%201%0AFROM%20%5BAdventure%20Works%5D%0AWHERE%0A%20%20(%0A%20%20%20%20%5BDate%5D.%5BCalendar%5D.%5BMonth%5D.%26amp%3B%5B2008%5D%26amp%3B%5B4%5D%0A%20%20%20%2C%5BCustomer%5D.%5BCity%5D.%26amp%3B%5BSeattle%5D%26amp%3B%5BWA%5D%0A%20%20)%3B%20%0A%3C%2FPRE%3E%0A%0A%3CP%3E%3CSTRONG%3E%20Scenario%207%20%E2%80%93%20Attribute%20relationship%20is%20defined%20with%20using%20EXISTING%20function%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3EInternet%20Sales%20Amount%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3EWashington%3C%2FTD%3E%0A%20%3CTD%3E%243%2C527.85%3C%2FTD%3E%0A%20%3CTD%3ESeattle's%20value%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3Ea%3C%2FTD%3E%0A%20%3CTD%3E%24147%2C078.52%3C%2FTD%3E%0A%20%3CTD%3EThe%20slicer%20overwrites%20the%20SET.%E2%80%98a%E2%80%99%20shows%20the%20Washington's%20value%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%0A%3CP%3E%3CSTRONG%3E%20Scenario%208%20%E2%80%93%20No%20attribute%20relationship.%20Using%20EXISTING%20function%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%3E%0A%20%20%3CP%3EInternet%20Sales%20Amount%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%26nbsp%3B%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3EWashington%3C%2FTD%3E%0A%20%3CTD%3E%243%2C527.85%3C%2FTD%3E%0A%20%3CTD%3ESeattle's%20value%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%3Ea%3C%2FTD%3E%0A%20%3CTD%3E%243%2C527.85%3C%2FTD%3E%0A%20%3CTD%3ESeattle's%20value%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%0A%0A%3CP%3E%3CSTRONG%3E%20Remark%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EBased%20on%20the%20testing%2C%20if%20you%20have%20attribute%20relationship%20defined%20(you%20should%20for%20best%20practices%20and%20performance%20reasons)%2C%20we%20should%20use%20EXISTING%20function%20to%20force%20a%20specified%20set%20to%20be%20evaluated%20within%20the%20current%20context.%3C%2FP%3E%0A%0A%3CP%3E%20%3CSTRONG%3EC%20S%20John%20Lam%20%3C%2FSTRONG%3E%20%7C%20Premier%20Field%20Engineer%20-%20SQL%20Business%20Intelligence%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-370370%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Feb%2011%2C%202013%20The%20SET%20overwrite%20is%20largely%20impacted%20by%20the%20attribute%20relationships%20and%20the%20behavior%20does%20depend%20on%20whether%20the%20attribute%20is%20below%20or%20above%20or%20no%20relationship%20in%20the%20relationship%20chains.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-370370%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAnalysis%20Services%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Emdx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

First published on MSDN on Feb 11, 2013

The SET overwrite is largely impacted by the attribute relationships and the behavior does depend on whether the attribute is below or above or no relationship in the relationship chains.

For illustrate the point, I run a test base on the following test environment:

Case 1:  The SET is in [City] level. The slicer is in [State-Province] level. [State-Province] is 1 to many to [City]. [City] is in the below the relationship chain.

Here is the example query

WITH
  MEMBER [customer].[city].a AS
    Aggregate
    (
      {
        [Customer].[City].&[Redwood City]&[CA]
       ,[Customer].[City].&[Spokane]&[WA]
       ,[Customer].[City].&[Seattle]&[WA]
      }
    )
SELECT
  [Measures].[Internet Sales Amount] ON 0
 ,{
    [Customer].[City].&[Redwood City]&[CA]
   ,[Customer].[City].&[Spokane]&[WA]
   ,[Customer].[City].&[Seattle]&[WA]
   ,[customer].[city].a
  } ON 1
FROM [Adventure Works]
WHERE
  (
    [Date].[Calendar].[Month].&[2008]&[4]
   ,[Customer].[State-Province].&[WA]&[US]
  ); 

Scenario 1: Attribute Relationship is defined

If we keep the existing attribute relationship defined between [City] and [State-Province] in the sample [AdventureWorksDW2012Multidimensional-EE] database, we get the following result

  Internet Sales Amount

Spokane

Seattle

$6,275.72

$3,527.85

a

$18,890.50

The SET ignores the slicer in WHERE clause. The value of "a" includes the value from Redwood City, CA

Scenario 2: Attribute Relationship is NOT defined

If we remove the attribute relationship between [City] and [State-Province] from the dimension, the concept of “auto exist” kicks in. The aggregation value of a does not include Redwood City, CA anymore.

  Internet Sales Amount

Spokane

Seattle

$6,275.72

$3,527.85

a

$9,803.57

The slicer in the WHERE clause overwrites the SET. The value of "a" does not includes Redwood City, CA

The use of existing function

Scenario 3: Attribute Relationship is defined

WITH
  MEMBER [customer].[city].a AS
    Aggregate
    (
      (EXISTING
        {
          [Customer].[City].&[Redwood City]&[CA]
         ,[Customer].[City].&[Spokane]&[WA]
         ,[Customer].[City].&[Seattle]&[WA]
        })
    )
SELECT
  [Measures].[Internet Sales Amount] ON 0
 ,{
    [Customer].[City].&[Redwood City]&[CA]
   ,[Customer].[City].&[Spokane]&[WA]
   ,[Customer].[City].&[Seattle]&[WA]
   ,[customer].[city].a
  } ON 1
FROM [Adventure Works]
WHERE
  (
    [Date].[Calendar].[Month].&[2008]&[4]
   ,[Customer].[State-Province].&[WA]&[US]
  ); 
  Internet Sales Amount

Spokane

Seattle

$6,275.72

$3,527.85

a

$9,803.57

With EXISTING function, the Slicer in the WHERE clause overwrites the SET

Scenario 4:

The EXISTING function has no impact on the result if no attribute relationships are defined.

You get the same result just as without using the Existing function

  Internet Sales Amount

Spokane

Seattle

$6,275.72

$3,527.85

a

$9,803.57

Case 2: The SET is in [State-Province] level. The slicer is in [City] level. [State-Province] is 1 to many to [City]. [State-Province] is in the above the relationship chain.

WITH
  MEMBER [Customer].[State-Province].[a] AS
    Aggregate
    (
      {
        [Customer].[State-Province].&[CA]&[US]
       ,[Customer].[State-Province].&[WA]&[US]
      }
    )
SELECT
  [Measures].[Internet Sales Amount] ON 0
 ,{
    [Customer].[State-Province].&[CA]&[US]
   ,[Customer].[State-Province].&[WA]&[US]
   ,[Customer].[State-Province].[a]
  } ON 1
FROM [Adventure Works]
WHERE
  (
    [Date].[Calendar].[Month].&[2008]&[4]
   ,[Customer].[City].&[Seattle]&[WA]
  ); 
 

Internet Sales Amount

 
Washington $3,527.85 It contains the value for Seattle only
a $462,840.69 'a' shows the value for Washington

Scenario 6 – Attribute relationship is NOT defined

 

Internet Sales Amount

 
Washington $3,527.85 Seattle's
a $3,527.85 The slicer overwrites the SET

Adding EXISTING function

WITH
  MEMBER [Customer].[State-Province].[a] AS
    Aggregate
    (
      (EXISTING
        {
          [Customer].[State-Province].&[CA]&[US]
         ,[Customer].[State-Province].&[WA]&[US]
        })
    )
SELECT
  [Measures].[Internet Sales Amount] ON 0
,{
    [Customer].[State-Province].&[CA]&[US]
   ,[Customer].[State-Province].&[WA]&[US]
   ,[Customer].[State-Province].[a]
  } ON 1
FROM [Adventure Works]
WHERE
  (
    [Date].[Calendar].[Month].&[2008]&[4]
   ,[Customer].[City].&[Seattle]&[WA]
  ); 

Scenario 7 – Attribute relationship is defined with using EXISTING function

 

Internet Sales Amount

 
Washington $3,527.85 Seattle's value
a $147,078.52 The slicer overwrites the SET.‘a’ shows the Washington's value

Scenario 8 – No attribute relationship. Using EXISTING function

 

Internet Sales Amount

 
Washington $3,527.85 Seattle's value
a $3,527.85 Seattle's value

Remark

Based on the testing, if you have attribute relationship defined (you should for best practices and performance reasons), we should use EXISTING function to force a specified set to be evaluated within the current context.

C S John Lam | Premier Field Engineer - SQL Business Intelligence