我使用SSAS
和Adventure Works DW 2008
。
获得此内容的MDX
是什么?:
措施:Reseller Sales Amount
日:2014/03/05
和
月= 2014/03(总和(第01-05天))
和
2014年(总和(Mount 01和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]
答案 0 :(得分:1)
以下指定一些特定日期,然后创建calculated member
。
我不是100%确定你需要什么,但是下面的方向正朝着正确的方向发展?
注意:我的冒险作品中的日期范围与您相同。
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]