当我深入研究日期层次结构(称为 CLM_THRU_DT)的不同级别时,我尝试返回支出的百分比变化。目前它没有返回值或错误,只是一个空白列或度量。
这是我一直在尝试的代码。任何帮助都将不胜感激。
% Change column =
VAR PreviousValue =
SWITCH( True(),
ISINSCOPE(AverageExpense_Grouptin[CLM_THRU_DT].[Day]),
CALCULATE(
SUM(AverageExpense_Grouptin[Spend]),
DATEADD('AverageExpense_Grouptin'[CLM_THRU_DT],-1,DAY)
),
ISINSCOPE(AverageExpense_Grouptin[CLM_THRU_DT].[Month]),
CALCULATE(
SUM(AverageExpense_Grouptin[Spend]),
PARALLELPERIOD('AverageExpense_Grouptin'[CLM_THRU_DT],-1,Month)
),
ISINSCOPE(AverageExpense_Grouptin[CLM_THRU_DT].[Quarter]),
CALCULATE(
SUM(AverageExpense_Grouptin[Spend]),
PARALLELPERIOD('AverageExpense_Grouptin'[CLM_THRU_DT],-1,Quarter)
),
ISINSCOPE(AverageExpense_Grouptin[CLM_THRU_DT].[Year]),
CALCULATE(
SUM(AverageExpense_Grouptin[Spend]),
PARALLELPERIOD('AverageExpense_Grouptin'[CLM_THRU_DT],-1,YEAR)
)
)
RETURN
DIVIDE(
SUM(AverageExpense_Grouptin[Spend]) - PreviousValue,
PreviousValue
)