Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Calculated Measure Crossjoins a Dimension

$
0
0

I have to build a handful of calculated measures which are filtered by a set of dimension attributes. Something similar to 

CREATE MEMBER CurrentCube.[Measures].[Measure A] 
AS ([Measures].[Real Measure])
	* { [Dimension 1].[Attribute A].[Name 1], [Dimension 1].[Attribute A].[Name 2] }
	* { [Dimension 2].[Attribute A].[Name 1], [Dimension 2].[Attribute A].[Name 3] };


Of course this works for reporting purposes, but of if a user is browsing using Excel and has "Measure A" on their values and brings on a hierarchy from Dimension 1 it creates a lovely cross join and brings back unexpected results.

So I tried to work around this by taking out the CROSSJOIN from the calculated measure and using a scope statement, and was able to successfully for Dimension 1. It looked something like this:

CREATE MEMBER CurrentCube.[Measures].[Measure A] 
AS ([Measures].[Real Measure])
	* { [Dimension 2].[Attribute A].[Name 1], [Dimension 2].[Attribute A].[Name 3] };



SCOPE ([Measures].[Measure A]);
	SCOPE ([Dimension 1].[Attribute A].[All];
		THIS = ([Measures].[Measure A])
			* { [Dimension 1].[Attribute A].[Name 1], [Dimension 1].[Attribute A].[Name 2] };
		SCOPE ([Dimension 1].[Attribute A].[All].Children);
			THIS = 0;
			SCOPE { [Dimension 1].[Attribute A].[Name 1], [Dimension 1].[Attribute A].[Name 2] };
				THIS = ([Measures].[Measure A]
					, [Dimension 1].[Attribute A].CURRENTMEMBER);
			END SCOPE;
		END SCOPE;
	END SCOPE;
END SCOPE;

This worked great in fixing what the users saw when they were browsing the cube with Excel, however it only works if they are using Attribute A of Dimension 1. Since Dimension 1 also has a Attribute B and C it still doesn't work right in all situations.

So what would the proper design pattern be here? 


Viewing all articles
Browse latest Browse all 14337

Trending Articles