Rolling 12 Month sum in PowerPivot

2019-07-11 12:42发布

In PowerPivot Excel 2016 I write a formula for rolling 12 month sum of sales as below :

Rolling Sum:=CALCULATE (
[Sales] ,
DATESBETWEEN (
    Sales[Date],
    FIRSTDATE(DATEADD(Sales[Date],-365,DAY)),
    LASTDATE (Sales[Date] )
 )
)

But it seems not working correctly. for each month it shows me only sales of that month! Does anybody knows how should I fix my problem?!

Thanks In Advance

1条回答
来,给爷笑一个
2楼-- · 2019-07-11 13:23

If you don't have a Date/Calendar table you can't use Time Intelligence functions properly.

Despite the best practice would be have a Calendar/Date table and use Time Intelligence functions, you can get the desired result by using an explicit filter:

Rolling Sum :=
CALCULATE (
    [Sales],
    FILTER (
        ALL ( Sales ),
        [Date]
            >= MAX ( Sales[Date] ) - 365
            && [Date] <= MAX ( Sales[Date] )
    )
)

Let me know if this helps.

查看更多
登录 后发表回答