Question

I use SSAS and Adventure Works DW 2008.

What is the MDX to get this?:

Measure: Reseller Sales Amount
Day : 2014/03/05 and
Month = 2014/03 ( Sum(Day 01-05) )
and
Year 2014 (Sum(Mount 01 and 02) + Sum(Day 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]
Was it helpful?

Solution

The following specifies some specific dates and then creates a calculated member.

I'm not 100% sure what you require but is the following heading in the right direction?

note: I don't have the same date ranges in my Adventure works as you.

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]

If you'd like all dates (with data) on rows and then various measures on the columns, such as mtd and ytd then you can do something like the following:

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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top