Rolling 3 Month Average
Here is a report formula that returns a rolling 3 month average. FID 7 is [Bill Creation Date], FID 9 is a field I am using to filter records, and FID 18 is the currency field that is being averaged. If you want to do 6 months average, just change the -2's to -6's for the month string.
var text QUERY = "{7.OAF.'" & ToDate(
//create 2-digit month
If(ToNumber(Month([Bill Creation Date]))=2,"12",
If(ToNumber(Month([Bill Creation Date]))=1,"11",
If(ToNumber(Month([Bill Creation Date]))<10,"0" & ToText(Month([Bill Creation Date])-2),
ToText(Month([Bill Creation Date])-2)))) &
// first day
"/01/" &
//create 4-digit year
If(ToNumber(Month([Bill Creation Date]))<=2,ToText(Year([Bill Creation Date])-1),
ToText(Year([Bill Creation Date]))))
& "'}AND{7.OBF.'" & LastDayOfMonth([Bill Creation Date]) & "'}AND{9.CT.'TEXT_STRING_FILTER'}";
SumValues(GetRecords($QUERY),18)/Size(GetRecords($QUERY))
Hope you find this useful.
P.S. @Sharon Faust thanks for sharing your tips on report formulas!
------------------------------
Adam Keever
------------------------------