Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |