0

我使用SSASAdventure Works DW 2008

什么是MDX得到这个?:

测量:Reseller Sales Amount
日:2014/03/05 和
月 = 2014/03(总和(01-05 天))

2014 年(总和(01 和 02 号山)+ 总和(01-05 天))

With 
set Serial_Month as
    [Date].[Calendar].Currentmember.parent.FIRSTSIBLING
                    :
    [Date].[Calendar].Currentmember.parent
set Serial_Day as 
    [Date].[Calendar].Currentmember.FIRSTSIBLING
                    :
    [Date].[Calendar].Currentmember
Select
non empty 
{
    [Date].[Calendar].[Date],
    Serial_Day,
    Serial_Month
} on  columns ,
non empty {[Measures].[Reseller Sales Amount]} on rows
From [Adventure Works]
4

1 回答 1

1

下面指定一些特定日期,然后创建一个calculated member.

我不是 100% 确定您需要什么,但以下方向是否正确?

注意:我的 Adventure 作品中的日期范围与您不同。

WITH 
SET [SpecificDate] AS
    [Date].[Calendar].[Date].&[20080401]
SET [SpecificMonths] AS
    {   [Date].[Calendar].[Month].&[2008]&[3]: 
        [Date].[Calendar].[Month].&[2008]&[7] }
MEMBER [Date].[Calendar].[AggregatedMonths]     AS 
    (
        AGGREGATE([SpecificMonths])
    )
SET [SpecificYear] AS
    [Date].[Calendar].[Calendar Year].&[2008]
MEMBER [Date].[Calendar].[CalcMember]   AS 
    (
        [Date].[Calendar].[Date].&[20080401] + 
        [Date].[Calendar].[Month].&[2008]&[3] + 
        [Date].[Calendar].[Calendar Year].&[2008]
    )
Select
{
    [Measures].[Reseller Sales Amount]
} ON COLUMNS, 
{
    [SpecificDate],
    [SpecificMonths],
    [Date].[Calendar].[AggregatedMonths],
    [SpecificYear],
    [Date].[Calendar].[CalcMember]
} ON ROWS
FROM [Adventure Works]

如果您希望行上的所有日期(带数据),然后列上的各种度量,例如mtd然后ytd您可以执行以下操作:

With 
MEMBER [Measures].[CurrentDay] AS
    AGGREGATE( 
        [Date].[Calendar].Currentmember,
        [Measures].[Reseller Sales Amount]
    )
MEMBER [Measures].[CurrentMonth] AS
  AGGREGATE( 
        [Date].[Calendar].Currentmember.parent,
        [Measures].[Reseller Sales Amount]
    )
MEMBER [Measures].[CurrentMTD] AS
    AGGREGATE(
            MTD([Date].[Calendar].CURRENTMEMBER),
            [Measures].[Reseller Sales Amount]
    )
MEMBER [Measures].[CurrentYTD] AS
    AGGREGATE(
            YTD([Date].[Calendar].CURRENTMEMBER),
            [Measures].[Reseller Sales Amount]
    )
Select
    non empty 
    {
        [Measures].[CurrentDay],
        [Measures].[CurrentMonth],
        [Measures].[CurrentMTD],
        [Measures].[CurrentYTD]
    } 
    on  columns,
    non empty 
    {
        [Date].[Calendar].[Date]
    }
    having [Measures].[CurrentDay]<>null 
    on rows
From [Adventure Works]
于 2014-05-01T08:27:05.190 回答