Forum Discussion
DianaDM96
10 months agoFrequent Visitor
Count Lastest Records Before Selected Date
Hello community, I have the follwoing data model: Date (1-*) Employees (1-*) Events. Sample data from Employees: End of Month Employee ID Employee Status Labour Type 7/31/20...
- 10 months ago
Hi,
See if my solution in this PBI file helps.
Kedar_Pande
Super User
10 months ago
You're overcomplicing this. Use LASTDATE within the date context.
Create this measure:
Headcount =
VAR SelectedDate = MAX('Date'[Date])
RETURN
CALCULATE(
DISTINCTCOUNT(Employees[Employee ID]),
FILTER(
ALL(Employees),
Employees[End of Month] =
CALCULATE(
LASTDATE(Employees[End of Month]),
ALL('Date'),
Employees[End of Month] <= SelectedDate
)
),
Employees[Employee Status] = "Active"
)