Kane_Heramb
New Member
- Joined
- Feb 19, 2023
- Messages
- 1
- Office Version
- 2021
- 2019
- 2016
- Platform
- Windows
Hi,
I am trying to calculate rolling 12 months total of the leavers using the DAX formula in power pivot. I am using is -
'Rolling 12M Leavers' =CALCULATE(COUNT(Exit_Base_Data[Leavers]),DATESINPERIOD(Exit_Base_Data[Leaving month],MAX(Exit_Base_Data[Leaving month]),-12,MONTH))
where Exit_Base_Data is a list of leavers, column [Leavers] is a flag/counter and column [Leaving month] is the month in which person has left. In pivot I also have few additional filters like Gender, leaving to external entity or internal movement etc.
The above formula works fine and provides the 12 month rolling total of leavers. Only problem is for the month when there is no leaver that meets the filtering criteria, the rolling total disappears for that particular month.
e.g. If I am looking at Female leavers for past 12 months
So, for Mar, Sep and Oct - the measure 'Rolling 12M Leavers' did not return anything, for rest of the months, it returns the correct 12 month rolling total.
Anyway to fix this? I also tried using 'Calendar' table
'Rolling 12M Leavers' =CALCULATE(COUNT(Exit_Base_Data[Leavers]),DATESINPERIOD('Calendar'[month],MAX('Calendar'[month]),-12,MONTH))
But this one returns the monthly number (the actual leavers column) and not the 12 month rolling.
Any suggesions?
I am trying to calculate rolling 12 months total of the leavers using the DAX formula in power pivot. I am using is -
'Rolling 12M Leavers' =CALCULATE(COUNT(Exit_Base_Data[Leavers]),DATESINPERIOD(Exit_Base_Data[Leaving month],MAX(Exit_Base_Data[Leaving month]),-12,MONTH))
where Exit_Base_Data is a list of leavers, column [Leavers] is a flag/counter and column [Leaving month] is the month in which person has left. In pivot I also have few additional filters like Gender, leaving to external entity or internal movement etc.
The above formula works fine and provides the 12 month rolling total of leavers. Only problem is for the month when there is no leaver that meets the filtering criteria, the rolling total disappears for that particular month.
e.g. If I am looking at Female leavers for past 12 months
Month | Actual Leavers | 12 month Rolling total leavers. (Assuming prior to Jan there are zero leavers) |
Jan | 1 | 1 |
Feb | 2 | 3 |
Mar | 3 | |
Apr | 4 | 7 |
May | 2 | 9 |
Jun | 1 | 10 |
Jul | 4 | 14 |
Aug | 7 | 21 |
Sep | 21 | |
Oct | 21 | |
Nov | 3 | 24 |
Dec | 1 | 25 |
So, for Mar, Sep and Oct - the measure 'Rolling 12M Leavers' did not return anything, for rest of the months, it returns the correct 12 month rolling total.
Anyway to fix this? I also tried using 'Calendar' table
'Rolling 12M Leavers' =CALCULATE(COUNT(Exit_Base_Data[Leavers]),DATESINPERIOD('Calendar'[month],MAX('Calendar'[month]),-12,MONTH))
But this one returns the monthly number (the actual leavers column) and not the 12 month rolling.
Any suggesions?