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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I want to calculate headcount for the chosen End of Month (Nov-22) in this case. An employee can hae multiple date_to and Date_from records which captures the change of contract. Here is the situation:
For the above sample data
Total Employees =
VAR min_snapshot = CALCULATE(MIN(Parameter[End of Month]), ALLSELECTED())
VAR max_snapshot = CALCULATE(MAX(Parameter[End of Month]), ALLSELECTED())
VAR max_snapshot_2 = CALCULATE(MAX(Parameter[End of Month])+7, ALLSELECTED())
RETURN
CALCULATE(
DISTINCTCOUNT(unitt_hrreport_employee[user_id]),
UNION(
CALCULATETABLE(
VALUES(unitt_hrreport_employee[user_id]),
(
((unitt_hrreport_employee[date_from] > max_snapshot && unitt_hrreport_employee[date_from] < max_snapshot_2)
&& (unitt_hrreport_employee[date_to] > max_snapshot_2 || ISBLANK(unitt_hrreport_employee[date_to]) = TRUE))
),
FILTER(unitt_hrreport_employee, unitt_hrreport_employee[min_date_from_per_user_id] <= max_snapshot)
),
CALCULATETABLE(
VALUES(unitt_hrreport_employee[user_id]),
(
(unitt_hrreport_employee[date_from] <= max_snapshot
&& (unitt_hrreport_employee[date_to] > max_snapshot || ISBLANK(unitt_hrreport_employee [date_to] ) = TRUE)
)
))))
@tamerj1 @amitchandak @johnt75 @andhiii079845 @FreemanZ @Greg_Deckler Please help
User | Count |
---|---|
10 | |
9 | |
7 | |
4 | |
4 |