Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48061

Re: Calculating moving average

$
0
0

Hi Philip,

 

Glad it works for you.
regarding your question 2, just remove 31 days to sdate : this is sdate that contains the start date of the first result.

 

regarding 1, there is a function EDATE that should do it:

Amount MAVG2b =
var sdate=Min(Amounts[Date])+365-31 // This is the month when to start displaying results (used below in IF)
var d = 'Amounts'[Date]  // the current date
var d365 =EDATE(d,-12)  // this calculates a date 12 months before (i assume it works with leap years)
var r=
IF(d>=sdate,
 SUMX(
  FILTER('Amounts',  Amounts[Date] <= d  && Amounts[Date] > d365),
  [Amount]
  )
 /12  
)
RETURN
r


Viewing all articles
Browse latest Browse all 48061

Trending Articles