Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

date filtering

I am trying to figure out why the formula below fail to calculate number of employees leaving the organization during the past 12 months. The formula seems to stop working sometime in 2020. The rolling 12 months exit number reported for 2020 Dec (i.e., # leavers from 2021-1-1 till 2021-12-31) is only 572. This is quite low comparing with # leavers (# of leavers during the month).  

 

Rolling 12 Months #Exits =

VAR Maxdate =

MAX ( 'Calendar'[Date] )

RETURN

CALCULATE (

COUNTROWS ( Headcount ),

USERELATIONSHIP ( 'Calendar'[Date], Headcount[Exit Date] ),

NOT ISBLANK ( Headcount[Exit Date] ),

FILTER (

ALL ( 'Calendar'[Date] ),

AND (

'Calendar'[Date] <= Maxdate,

DATEADD ( 'Calendar'[Date], 1, YEAR ) > Maxdate

)

)

)

 

date filtering.PNG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like 

 

CALCULATE (
CALCULATE (
	COUNTROWS ( Headcount ),
	USERELATIONSHIP ( 'Calendar'[Date], Headcount[Exit Date] ),
	NOT ISBLANK ( Headcount[Exit Date] )),,DATESINPERIOD('Calendar'[Date ],MAX('Calendar'[Date ]),-12,MONTH))  
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like 

 

CALCULATE (
CALCULATE (
	COUNTROWS ( Headcount ),
	USERELATIONSHIP ( 'Calendar'[Date], Headcount[Exit Date] ),
	NOT ISBLANK ( Headcount[Exit Date] )),,DATESINPERIOD('Calendar'[Date ],MAX('Calendar'[Date ]),-12,MONTH))  
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks! Your solution should work. My measure failed because the dateadd() part doesn't work properly. My celandar[Date] ends at 2021-03-01, that means if the date context is 2020-04-01, the dateadd('Calendar'[Date], 1, YEAR ) function will not work because it exceeds the max date in the calendar. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors