I've been working on writing a dax so that I can get the sum sales amount for the last 12 calendar months. I've played with ALL and KEEPFILTERS but I still can't seem to get it. Below is an example of what I've tried. But I don't want just 365 days back.. I would like 12 Calendar Months (or I would settle for going back to the 1st day of 12 calendar months and then ending on today). IE: Today it would be 1/1/19 to 2/6/2020 '''
var varToday = Today()
var varYearAgo = varToday - 365
RETURN
CALCULATE(
SUM(FACT[Earnings]),
FILTER('Earnings',
'Earnings'[PayDate] <= varToday
&& 'Earnings'[PayDate]>= varYearAgo
))
'''
Below is howt he data looks
I have added a calendar table as well: DimCalendar and attempted this as my DAX
'''
var varEarnings = SUM(Fact[Earnings])
RETURN
CALCULATE (
varEarnings ,
ALLEXCEPT ( DIMCalendar, DIMCalendar[Date] ),
DATESINPERIOD( DIMCalendar[Date], today(), -12, MONTH )
)
'''