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!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hello Community,
I need some help with correcting my dax formula. My ending_hc is working as expected but my starting_hc isn't. Please find below table with the details.
Ending_HC =
CALCULATE(
COUNTROWS('Headcount Report'),FILTER('Headcount Report',
'Headcount Report'[YEAR ] = SELECTEDVALUE('Headcount Report'[YEAR ]) &&
'Headcount Report'[MONTH#] = SELECTEDVALUE('Headcount Report'[MONTH#])
))
Starting HC =
VAR _CurrentYear = SELECTEDVALUE('Headcount Report'[YEAR ])
VAR _CurrentMonth = SELECTEDVALUE('Headcount Report'[MONTH#])
VAR _PreviousMonth = IF(_CurrentMonth = 1, 12, _CurrentMonth-1)
VAR _PreviousYear = IF(_CurrentMonth = 1, _CurrentYear-1, _CurrentYear)
var edhc = CALCULATE(
COUNTROWS('Headcount Report'),FILTER('Headcount Report',
'Headcount Report'[YEAR ] = _PreviousYear &&
'Headcount Report'[MONTH#] = _PreviousMonth
))
RETURN
IF(_CurrentYear=2021 && _CurrentMonth=2,[Starting_HC],edhc)
My output -
@Ritaf1983
Warm Regards
Solved! Go to Solution.
I found the answer,
I found the answer,
try this refined measure and apply your logic to it:
Starting_HC =
VAR _CurrentYear = SELECTEDVALUE('Headcount Report'[YEAR ])
VAR _CurrentMonth = SELECTEDVALUE('Headcount Report'[MONTH#])
VAR _PreviousMonth = IF(_CurrentMonth = 1, 12, _CurrentMonth - 1)
VAR _PreviousYear = IF(_CurrentMonth = 1, _CurrentYear - 1, _CurrentYear)
VAR _StartingHC =
CALCULATE(
COUNTROWS('Headcount Report'),
FILTER(
'Headcount Report',
'Headcount Report'[YEAR ] = _PreviousYear &&
'Headcount Report'[MONTH#] = _PreviousMonth
)
)
RETURN
IF(
ISBLANK(_StartingHC),
0,
_StartingHC
)
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.