Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

How to calculate rolling average with duplicate dates

Hi everyone,

 

I need your help to get the rolling average of my transactions ($) with duplicate dates. 

 

here is a snippet of my data -

 

As you may notice, the date column has duplicate values.

 

these are the formulas i tried

30 Rolling Avg =
var Transactions =
CALCULATE([Sum of Transactions],
DATESINPERIOD('Transaction'[Date].[Date], LASTDATE('Transaction'[Date].[Date]), -30, DAY))
var Dates_in_period =
CALCULATE(
DISTINCTCOUNT('Transaction'[Date].[Date]), DATESINPERIOD('Transaction'[Date].[Date], LASTDATE('Transaction'[Date].[Date]), -30, DAY))
return
Transactions/Dates_in_period


30 Avg X = AVERAGEX(DATESINPERIOD('Transaction'[Date].[Date], LASTDATE('Transaction'[Date].[Date]),-30, DAY), SUM('Transaction'[Transactions]))


Result:

the 30 Rolling Avg is returning blank, while 30 Avg X column is the same as Transactions.

 

 

 

What could be wrong in my formula? What did i missed? Thank you in advance! 

2 Replies