Code: Select all
dDimName = 'Versions';
PriorMonthForecast = 'Mar Forecast';
PriorMonthSnapshot_1 = 'Mar Forecast';
PriorMonthSnapshot_2 = 'Jan Forecast';
# Paul - slightly improved code but returning duplicates
sSubName = '1 - Paul';
SubsetCreate( dDimName, sSubName );
SubsetElementInsert( dDimName, sSubName, 'Planning', 0 );
SubsetElementInsert( dDimName, sSubName, 'Budget', 0 );
SubsetElementInsert( dDimName, sSubName, PriorMonthForecast, 0 );
SubsetElementInsert( dDimName, sSubName, 'Jan Forecast', 0 );
SubsetElementInsert( dDimName, sSubName, 'Mar Forecast', 0 );
SubsetElementInsert( dDimName, sSubName, PriorMonthSnapshot_1, 0 );
SubsetElementInsert( dDimName, sSubName, PriorMonthSnapshot_2, 0 );
# Lotsa - operator + to return a distinct list
# [There were too many elements in the list compared to Paul's example]
sSubName = '2 - Lotsa';
SubsetCreate( dDimName, sSubName );
SubsetMDXSet( dDimName, sSubName, Expand( '{{[%dDimName%].[Planning]}+{[%dDimName%].[Budget]}+{[%dDimName%].[%PriorMonthForecast%]}+{[%dDimName%].[Jan Forecast]}+{[%dDimName%].[Mar Forecast]}+{[%dDimName%].[%PriorMonthSnapshot_1%]}+{[%dDimName%].[%PriorMonthSnapshot_2%]}}' ));
# Wim - function Union to return a distinct list works BUT remember that Union only works on pairs
sSubName = '3 - Wim';
SubsetCreate( dDimName, sSubName );
SubsetMDXSet( dDimName, sSubName, Expand( 'Union( {[%dDimName%].[Planning]}, { {[%dDimName%].[Budget]}, {[%dDimName%].[%PriorMonthForecast%]}, {[%dDimName%].[Jan Forecast]}, {[%dDimName%].[Mar Forecast]}, {[%dDimName%].[%PriorMonthSnapshot_1%]}, {[%dDimName%].[%PriorMonthSnapshot_2%]} } )' ));
# George - function Distinct to return a distinct list
sSubName = '4 - George';
SubsetCreate( dDimName, sSubName );
SubsetMDXSet( dDimName, sSubName, Expand( 'Distinct( { {[%dDimName%].[Planning]}, {[%dDimName%].[Budget]}, {[%dDimName%].[%PriorMonthForecast%]}, {[%dDimName%].[Jan Forecast]}, {[%dDimName%].[Mar Forecast]}, {[%dDimName%].[%PriorMonthSnapshot_1%]}, {[%dDimName%].[%PriorMonthSnapshot_2%]} } )' ));
# George - condensed coding but with a double Expand
sSubName = '4 - George - condensed';
d = '[%dDimName%].';
SubsetCreate( dDimName, sSubName );
SubsetMDXSet( dDimName, sSubName, Expand( Expand( 'Distinct( { {%d%[Planning]}, {%d%[Budget]}, {%d%[%PriorMonthForecast%]}, {%d%[Jan Forecast]}, {%d%[Mar Forecast]}, {%d%[%PriorMonthSnapshot_1%]}, {%d%[%PriorMonthSnapshot_2%]} } )' )));
# George - even more condensed coding
sSubName = '4 - George - even more condensed';
d = '[%dDimName%].';
SubsetCreate( dDimName, sSubName );
SubsetMDXSet( dDimName, sSubName, Expand( Expand( 'Distinct( { %d%[Planning], %d%[Budget], %d%[%PriorMonthForecast%], %d%[Jan Forecast], %d%[Mar Forecast], %d%[%PriorMonthSnapshot_1%], %d%[%PriorMonthSnapshot_2%] } )' )));