我只需要为Average Year To Date
个索赔计算Closed
。
如果我使用FILTER
函数,那么它会给我正确的结果:$ 3,507.74
AVG_YTD_Indemn_Closed =
CALCULATE (
AVERAGE ( fact_Losses[PaidIdemnity] ),
FILTER (
fact_Losses,
fact_Losses[DateEntered].[Year] = YEAR ( TODAY () )
&& fact_Losses[ClaimStatus] = "Closed"
)
)
但是,如果我使用TOTALYTD
函数,由于某种原因,我会得到不同的结果$ 4,702.31:
AVG_YTD_Indemn_Closed1 =
CALCULATE (
TOTALYTD ( AVERAGE ( fact_Losses[PaidIdemnity] ), dim_Date[Date] ),
fact_Losses[ClaimStatus] = "Closed"
)
为什么会有如此大的差异?函数TOTALYTD
如何计算与FILTER
不同的结果?
答案 0 :(得分:1)
如here所述,
TOTALYTD (
<EXPRESSION>,
<DATES>
[, <FILTER>]
[, <YEARENDDATE>]
)
等同于
CALCULATE (
<EXPRESSION>,
DATESYTD ( <DATES> [, <YEARENDDATE>] )
[, <FILTER>]
)
因此,您的TOTALYTD
度量等于
AVG_YTD_Indemn_Closed1 =
CALCULATE (
CALCULATE(
AVERAGE ( fact_Losses[PaidIdemnity] ),
DATESYTD( dim_Date[Date] )
),
fact_Losses[ClaimStatus] = "Closed"
)
如果理顺日期关系,我建议您使用此版本,因为TOTALYTD
无法容纳将来可能需要的其他过滤器,如here所述:
AVG_YTD_Indemn_Closed1 =
CALCULATE (
AVERAGE ( fact_Losses[PaidIdemnity] ),
DATESYTD( dim_Date[Date] ),
fact_Losses[ClaimStatus] = "Closed"
)