Question

If I run the following the two custom measures return the same results. Why doesn't [Measures].[AvgOfChildren] return the average for the level below [Calendar Year] ?

WITH MEMBER [Measures].[Avg Yearly Reseller Sales Amount] AS
    AVG(
        {[Date].[Calendar].[Calendar Year].MEMBERS},
        [Measures].[Reseller Sales Amount])
MEMBER [Measures].[AvgOfChildren] AS
    AVG(
        {[Date].[Calendar Year].CURRENTMEMBER.CHILDREN}, //[Date].[Calendar].[Month].MEMBERS
        [Measures].[Reseller Sales Amount])
SELECT
    {[Measures].[Avg Yearly Reseller Sales Amount],
    [Measures].[AvgOfChildren]} ON 0,
    {[Geography].[Geography].[Country].MEMBERS} ON 1
FROM [Adventure Works]
Était-ce utile?

La solution

Your statement does not contain any setting for the [Date].[Calendar Year] hierarchy, neither in a WHERE condition, nor in the rows. And this means that the CurrentMember has the default value, which is the ``All member, named All Periods in this case.

You can verify this by adding another calculated member

Measures.CurrentYear as [Date].[Calendar Year].CURRENTMEMBER.NAME

and adding that to your columns.

Autres conseils

I think you are not using the correct hierarchy to get the answer you are expecting.

You asked for [date].[calendar year].currentmember.children in your AvgOfChildren calculation, but I think you meant to use [date].[calendar].[calendar year].currentmember.children.

The [date].[calendar year] hierarchy is the one created for the calendar year attribute. The [date].[calendar] hierarchy is the user defined hierarchy with many levels that probably looks something like calendar year -> calendar quarter -> month -> date. When you ask for the children of the calendar year on this hierarchy you should expect the answer to be different because it is using quarter (or whatever you have as the level under calendar year).

You don't have a [Date].[Calendar Year].CurrentMember defined. There's no mention to the [Date] dimension in the Rows.

Try this instead:

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

The first column will give you the yearly average (same value for all years), the second will give you the average of the year's children.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top