Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello,
I'm trying to get number of active employees per month(s). I have folowing formula:
Solved! Go to Solution.
Hi @Lubeno78
Replace SELECTEDVALUE with MAX
ActiveEmployees per month =
VAR _EndOfMonth =
MAX ( EndMonth[EndMonth] )
VAR _calculation =
CALCULATE (
DISTINCTCOUNT ( HC[ID] ),
FILTER (
HC,
HC[Starting Date] < _EndOfMonth
&& OR ( ISBLANK ( HC[Ending Date] ), HC[Ending Date] >= _EndOfMonth )
)
)
RETURN
IF ( ISBLANK ( _calculation ), 0, _calculation )
@Lubeno78
I hope this will do the trick. Create 2 measures
ActiveEmployees per month =
VAR _EndOfMonth =
MAX ( EndMonth[EndMonth] )
VAR _calculation =
CALCULATE (
DISTINCTCOUNT ( HC[ID] ),
FILTER (
HC,
HC[Starting Date] < _EndOfMonth
&& OR ( ISBLANK ( HC[Ending Date] ), HC[Ending Date] >= _EndOfMonth )
)
)
RETURN
IF ( ISBLANK ( _calculation ), 0, _calculation )
ActiveEmployees RT =
VAR StartDate =
MIN ( EndMonth[EndMonth] )
VAR EndDate =
MAX ( EndMonth[EndMonth] )
RETURN
CALCULATE (
[ActiveEmployees per month],
EndMonth[EndMonth] >= StartDate,
EndMonth[EndMonth] <= EndDate
)
No I think this is wrong it will only return the last month. I will update tou with the correct solution
@Lubeno78
I hope this will do the trick. Create 2 measures
ActiveEmployees per month =
VAR _EndOfMonth =
MAX ( EndMonth[EndMonth] )
VAR _calculation =
CALCULATE (
DISTINCTCOUNT ( HC[ID] ),
FILTER (
HC,
HC[Starting Date] < _EndOfMonth
&& OR ( ISBLANK ( HC[Ending Date] ), HC[Ending Date] >= _EndOfMonth )
)
)
RETURN
IF ( ISBLANK ( _calculation ), 0, _calculation )
ActiveEmployees RT =
VAR StartDate =
MIN ( EndMonth[EndMonth] )
VAR EndDate =
MAX ( EndMonth[EndMonth] )
RETURN
CALCULATE (
[ActiveEmployees per month],
EndMonth[EndMonth] >= StartDate,
EndMonth[EndMonth] <= EndDate
)
Hi @Lubeno78
Replace SELECTEDVALUE with MAX
ActiveEmployees per month =
VAR _EndOfMonth =
MAX ( EndMonth[EndMonth] )
VAR _calculation =
CALCULATE (
DISTINCTCOUNT ( HC[ID] ),
FILTER (
HC,
HC[Starting Date] < _EndOfMonth
&& OR ( ISBLANK ( HC[Ending Date] ), HC[Ending Date] >= _EndOfMonth )
)
)
RETURN
IF ( ISBLANK ( _calculation ), 0, _calculation )
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 6 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 15 | |
| 8 | |
| 8 | |
| 8 |