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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
quyenduong
Helper II
Helper II

12M Rolling Metrics - DAX code - How to exclude the first 11 months

Dear community,

 

I have the following is DAX code in Power BI to calculate the Rolling 12 Attrition Rate = (sum of leavers in the last 12 months) / Average Headcount in the last month and it works properly:

 

Rolling 12M Attrition Rate =

VAR __NrOfRollingMonths = 12

VAR __CurrentDate = MAX ( 'Date Table'[Date] )

VAR __RollingMonths =

       FILTER (

            ALL ( 'Date Table' ), 'Date Table'[Date] > EDATE ( __CurrentDate, - __NrOfRollingMonths )

                 && 'Date Table'[Date] <= __CurrentDate

)

RETURN

       CALCULATE ( DIVIDE([Voluntary Leavers], AVERAGEX(VALUES('Date Table'[Report Month]),[Headcount Permanent Contract])), __RollingMonths )

 

However, for the first 11 months, it give very small % of Attrition because it doesnt have data of previous 12M (see red collumn).

quyenduong_0-1681897878170.png

(these numbers in the screenshot are modified and fictional, the screenshot is just to show the ideal outcome)


From the Date column from Date Table, how can we edit the DAX above to achieve the green column that:

- It calculates exactly the same logic

- Based on the column Date from Date Table, can you please give Attrition Rate blank for the first 11 months of the data, (the Date column from Date Table is everyday from January 2021 till March 2023) so I want from Jan 2021 till November 2021, the Attrition rate is blank

 

I tried several ways to edit this code but it doesnt work.  Thank you in advance for your answer. 

1 REPLY 1
Anonymous
Not applicable

HI @quyenduong,

You can add a variable to get the first date from current table records with filter effects, then you can package expression with if statement and use this variable as condition to compare with current axis date and skip the calculations if current date is included in the first 11 months.

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors