IIF(SUM
(
[Calendar].[Month].CurrentMember.Lag(17) :
[Calendar].[Month].CurrentMember,
[Measures].[Qty]
) = 0, 0,
SUM
(
[Calendar].[Month].CurrentMember.Lag(17) :
[Calendar].[Month].CurrentMember,
[Measures].[Local Num]
) /
SUM
(
[Calendar].[Month].CurrentMember.Lag(17) :
[Calendar].[Month].CurrentMember,
[Measures].[N Qty]
) )
我正在尝试将该mdx查询转换为dax公式。是否有任何简单的方法为该mdx查询编写dax公式?
答案 0 :(得分:0)
如果这是您需要的措施,请尝试以下方法:
ValueLast17Months:=
CALCULATE
(
DIVIDE(SUM([Local Num]),SUM([N Qty])),
DATESINPERIOD
(
'Calendar'[Month],
MAX('Calendar'[Month]),
-17,
MONTH
)
)
如果它是您需要的计算列,则可以使用:
ValueLast17Months
= DIVIDE(
SUMX(
FILTER
(
'Calendar',
MONTH('Calendar'[Month]) + 17 >= MONTH(EARLIER('Calendar'[Month])) &&
MONTH('Calendar'[Month]) <= MONTH(EARLIER('Calendar'[Month]))
)
,[Local Num]
)
,
SUMX(
FILTER
(
'Calendar',
MONTH('Calendar'[Month]) + 17 >= MONTH(EARLIER('Calendar'[Month])) &&
MONTH('Calendar'[Month]) <= MONTH(EARLIER('Calendar'[Month]))
)
,[N Qty]
)
)