去年当月的 MTD
MTD for current month in last year
如何计算去年当月的 MTD?下面查询 returns 12.2015 的总 [Net Sales Amount],但需要从 01.12.2015 到 09.12.2015(今天)的销售额。
SUM(
MTD(
ParallelPeriod(
[Calender].[YMD].[Month],
12,
[Calender].[YMD].CurrentMember
)
)
,[Measures].[Net Sales Amount]
)
我认为您需要使用您要查找的成员的 HEAD
:
SUM(
HEAD(
ParallelPeriod(
[Calender].[YMD].[Month],
12,
[Calender].[YMD].CurrentMember
).CHILDREN,
, 9
)
,[Measures].[Net Sales Amount]
)
以上假设在您的多维数据集设计中日期是月份的子项。
您需要使 9 动态化 - 您的多维数据集中有未来的日期吗?
如果您没有未来的日期,那么这可能有效:
WITH
MEMBER [Measures].[NumDaysInCurrentMonth] AS
Count(
Descendants(
TAIL([Date].[Calendar].[Month]).Item(0) //<<<not sure if Item(0) is required
,[Date].[Calendar].[Date]
,SELF
)
)
如果您有未来的约会对象,那么可能是:
WITH
MEMBER [Measures].[NumDaysInCurrentMonth] AS
count(
NONEMPTY(
Descendants(
TAIL([Date].[Calendar].[Month]).Item(0) //<<<not sure if Item(0) is required
,[Date].[Calendar].[Date]
,SELF
)
)
)
那么上面的一个可以馈入前面的:
WITH
MEMBER [Measures].[NumDaysInCurrentMonth] AS
COUNT(
Descendants(
TAIL([Date].[Calendar].[Month]).Item(0) //<<<not sure if Item(0) is required
,[Date].[Calendar].[Date]
,SELF
)
)
MEMBER [Measures].[PrevYearMTD] AS
SUM(
HEAD(
ParallelPeriod(
[Calender].[YMD].[Month],
12,
[Calender].[YMD].CurrentMember
).CHILDREN,
, [Measures].[NumDaysInCurrentMonth]
)
,[Measures].[Net Sales Amount]
)
如何计算去年当月的 MTD?下面查询 returns 12.2015 的总 [Net Sales Amount],但需要从 01.12.2015 到 09.12.2015(今天)的销售额。
SUM(
MTD(
ParallelPeriod(
[Calender].[YMD].[Month],
12,
[Calender].[YMD].CurrentMember
)
)
,[Measures].[Net Sales Amount]
)
我认为您需要使用您要查找的成员的 HEAD
:
SUM(
HEAD(
ParallelPeriod(
[Calender].[YMD].[Month],
12,
[Calender].[YMD].CurrentMember
).CHILDREN,
, 9
)
,[Measures].[Net Sales Amount]
)
以上假设在您的多维数据集设计中日期是月份的子项。
您需要使 9 动态化 - 您的多维数据集中有未来的日期吗?
如果您没有未来的日期,那么这可能有效:
WITH
MEMBER [Measures].[NumDaysInCurrentMonth] AS
Count(
Descendants(
TAIL([Date].[Calendar].[Month]).Item(0) //<<<not sure if Item(0) is required
,[Date].[Calendar].[Date]
,SELF
)
)
如果您有未来的约会对象,那么可能是:
WITH
MEMBER [Measures].[NumDaysInCurrentMonth] AS
count(
NONEMPTY(
Descendants(
TAIL([Date].[Calendar].[Month]).Item(0) //<<<not sure if Item(0) is required
,[Date].[Calendar].[Date]
,SELF
)
)
)
那么上面的一个可以馈入前面的:
WITH
MEMBER [Measures].[NumDaysInCurrentMonth] AS
COUNT(
Descendants(
TAIL([Date].[Calendar].[Month]).Item(0) //<<<not sure if Item(0) is required
,[Date].[Calendar].[Date]
,SELF
)
)
MEMBER [Measures].[PrevYearMTD] AS
SUM(
HEAD(
ParallelPeriod(
[Calender].[YMD].[Month],
12,
[Calender].[YMD].CurrentMember
).CHILDREN,
, [Measures].[NumDaysInCurrentMonth]
)
,[Measures].[Net Sales Amount]
)