This will do it, has to have something like month number in the rows or columns and needs to be filtered by a 'Year'
=CALCULATE([Sales],
FILTER(ALL(Calendar[Calendar Year]),Calendar[Calendar Year]<values(calendar[calendar year])))
/
CALCULATE([Sales],
FILTER(ALL(Calendar),Calendar[Calendar Year]<values(calendar[calendar year])))
Great thread.
</values(calendar[calendar></values(calendar[calendar>I'm working on something very similar, where I'm trying to forecast monthly sales by product by customer for next year, based on sales data of the last 12 months. The "allselected" function allows you to specify the historic period that forms the basis of the calculation, and doesn't require the filter to specify a particular year:
Fraction=divide([Sum of SALESORDERQTY],calculate([Sum of SALESORDERQTY],allselected(HistoricSales)),0)
You have to specify the 12 month time range in a slicer to take advantage of the "allselected" function. I use the "divide" function wherever possible as it automatically deals with division by zero. Each line in my historic sales table is related to a particular customer.
I have another calculated field where I multiply this fraction with my total expected sales quantity for next year (which I have already laboriously split out by product and month but not customer), but the trick here is to not link the master date table with the forecast period, otherwise it tries to split out the quantities out into the historical period again.
The only issue I'm then left with is rounding off decimal points to whole numbers (the products come in discrete unit quantities), which is mostly a problem for small customers.