Answer the question
In order to leave comments, you need to log in
WHERE inside a calculated measure? (MDX/OLAP)?
I create a cube in SQL Server Analysis Services; the following problem arose.
There is a dimension D and a measure M, connected as many-to-many (which is important).
I need to define a calculated measure using the formula M/Σ(M), where Σ is the sum of all the measure facts associated with at least one member of the current dimension. For example, I have a total for measure M of about 3,000,000, while the following query returns about 120,000:
SELECT [Measures].[M] ON 0
FROM [MyCube]
WHERE [D].[All].CHILDREN
CREATE MEMBER [Measures].[Calc] AS
[Measures].[M] / ( DRILLUPLEVEL( AXIS( 1 ).ITEM( 0 ).HIERARCHY.MEMBERS ).ITEM( 0 ), [Measures].[M] )
WHERE DRILLUPLEVEL( AXIS( 1 ).ITEM( 0 ).HIERARCHY.MEMBERS ).ITEM( 0 ).CHILDREN
Answer the question
In order to leave comments, you need to log in
As a result, I came to the following universal solution:
CREATE HIDDEN [Total M] =
AGGREGATE(
DESCENDANTS(
AXIS( 1 ).ITEM( 0 ).DIMENSION.LEVELS( 0 ).ITEM( 0 ),
AXIS( 1 ).ITEM( 0 ).DIMENSION.LEVELS.COUNT
) - AXIS( 1 ).ITEM( 0 ).DIMENSION.LEVELS( 0 ).ITEM( 0 ),
[Measures].[M]
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question