Question

One of the functions being used in a code sample is averageofchilren.

What exactly the AverageOfChildren aggregate function actually does?
How can we compare this with Avg() function in MDX ?

Was it helpful?

Solution

Maybe a custom measure is created in your cube.

Using AdventureWorks try this:

Script 1

SELECT
    {[Measures].[Reseller Sales Amount]} ON 0,
    NON EMPTY 
    {[Geography].[Geography].[Country].&[Australia].CHILDREN} ON 1
FROM [Adventure Works]
WHERE ([Date].[Calendar Year].&[2007])

That results in this:

enter image description here

Say I wanted to create a measure that returned the average reseller sales amount per region of each country then I could do the following:

Script 2

WITH 
    MEMBER [Measures].[AvgOfChildren] AS
        AVG(
                [Geography].[Geography].CURRENTMEMBER.CHILDREN,
                [Measures].[Reseller Sales Amount]
        )
SELECT
    { [Measures].[Reseller Sales Amount],
      [Measures].[AvgOfChildren]  
            } ON 0,
    {[Geography].[Geography].[Country].MEMBERS} ON 1
FROM [Adventure Works]
WHERE ([Date].[Calendar Year].&[2007])

You can see from the results for Australia (211,857.58) that the AverageOfChildren is the average of the numbers returned by script 1:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top