March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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 |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
86 | |
73 | |
58 | |
52 |
User | Count |
---|---|
196 | |
125 | |
107 | |
68 | |
65 |