Frage

I have a calculated member that looks like this:

Asian Weighted = ([Measures].[Asian] * [Measures].[Population]) 

My MDX query looks like this:

WITH
MEMBER [Measures].[AsianPop] AS 
(([Measures].[Asian Weighted], [Jurisdiction.BTA].[BTA].&[51]) / ([Jurisdiction.BTA].[BTA].&[51], [Measures].[Population]))
SELECT 
       {[Measures].[AsianPop]} ON 0
FROM 
       [Selection Statistics]

The problem is in the numerator. Asian and Population are both SUMMED before they are multiplied together. Is there a straightforward way to do a weighted average in MDX?

War es hilfreich?

Lösung

The solution that you described in your comment - pre-caclulating the measure to sum - is the best approach. In theory, you could implement the correct calculation purely in MDX, but this is complex and in many cases - at least in Analysis Services, I have no experience with Mondrian - really slow. You would have to instruct the MDX engine explicitly to do the multiplication on leaf level, and then aggregate. You could use functions like Leaves or Descendants to go to leaf level. You would have to think about the attributes for which you need to go down to leaf level, and for which attributes this may not be necessary. My assumption - as far as Analysis Services is concerned - is that as this uses a custom aggregation, all the built in aggregations which make the cube fast are not used.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top