Forum Discussion
Anonymous
6 years agoNot applicable
Rolling 12 Month calculation
Hi I am trying to calculate rolling 12-month headcount using below DAX formula, I have a data in monthly time series format with date ref column for month-end date of each month for each record ...
Anonymous
6 years agoNot applicable
// A proper Calendar table marked as the date table
// must be present for this to work correctly.
// It must be connected to the FactTable and
// slicing must be done only through dimensions.
// In a word, all the best practices must be
// followed in the model.
HeadCount L12M =
var __lastVisibleDate = LASTDATE( 'Calendar'[Date] )
var __canMove12MBack =
NOT ISBLANK( dateadd( __lastVisibleDate, -1, Year) )
var __result =
CALCULATE(
SUM( FactTable[HeadCount] ),
DATESINPERIOD(
Calendar[Date],
__lastVisibleDate,
-1,
Year
)
)
return
if( __canMove12MBack, __result )
Here's something about proper designs and time-intel:
https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/
https://www.youtube.com/watch?v=_quTwyvDfG0
Best
D