Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi
I'm fairly new to PowerBI and need some help with a formula I have please.
Table Name: 'Staff Data'
What I'm trying to do it count the number of leavers on a staff list over a rolling 12 complete months period. Meaning, today is the 22nd February 2022 so if I refreshed the data it would count all rows of data which contained an leave date [Date Left] from 01/02/2021 (var _min) to 31/01/2022 (var _max). I also have a flag which determines whether each member of staff left voluntarily [Vol. Leaver].
The variables look correct to me so is there something incorrect with the way I am using the filter?
Vol.LeaversLTM =
var _min = EDATE(EOMONTH(today(),-1),-12)+1
var _max = EOMONTH(today(),-1)
return COUNTROWS(CALCULATETABLE('Staff Data',FILTER('Staff Data',[Date Left] <= _max && 'Staff Data'[Date Left] >=_min),FILTER('Staff Data','Staff Data'[Vol. Leaver]= "yes")))
Thanks for any help you can give me.
Solved! Go to Solution.
Hi @drewmcspy ,
Try this:
Vol.LeaversLTM =
VAR _min =
EDATE ( EOMONTH ( TODAY (), -1 ), -12 ) + 1
VAR _max =
EOMONTH ( TODAY (), -1 )
RETURN
COUNTROWS (
FILTER (
ALL ( 'Staff Data' ),
'Staff Data'[Date Left] <= _max
&& 'Staff Data'[Date Left] >= _min
&& 'Staff Data'[Vol. Leaver] = "yes"
)
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @drewmcspy ,
Try this:
Vol.LeaversLTM =
VAR _min =
EDATE ( EOMONTH ( TODAY (), -1 ), -12 ) + 1
VAR _max =
EOMONTH ( TODAY (), -1 )
RETURN
COUNTROWS (
FILTER (
ALL ( 'Staff Data' ),
'Staff Data'[Date Left] <= _max
&& 'Staff Data'[Date Left] >= _min
&& 'Staff Data'[Vol. Leaver] = "yes"
)
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @drewmcspy,
Does it work with this?
Vol.LeaversLTM =
var _min = EDATE(EOMONTH(today(),-1),-12)+1
var _max = EOMONTH(today(),-1)
return
CALCULATE (
COUNTROWS ( 'Staff Data' ),
FILTER ('Staff Data', 'Staff Data'[Date Left] <= _max && 'Staff Data'[Date Left] >= _min && 'Staff Data'[Vol. Leaver] = "yes")
)
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
| Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
| Also happily accepting Kudos 🙂 |
| Feel free to connect with me on LinkedIn! | |
| #proudtobeasuperuser | |
Thanks for your reply. Unfortunately it doesn't It produces the same result as my original filter. The figure should be about 200 but I'm getting 32. I can't see how.
mcspy
Hi @drewmcspy ,
Please can you share the data and the result you would like to achieve? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
| Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
| Also happily accepting Kudos 🙂 |
| Feel free to connect with me on LinkedIn! | |
| #proudtobeasuperuser | |
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 45 | |
| 42 | |
| 20 | |
| 18 |