Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello everyone!
I'm excited to make my first post on this forum and to be a part of the Power BI community.
I've been exploring Power BI for about a year and am encountering a challenge with the following formula:
Headcount Status =
VAR SelectedDate = MAX('DateDimensionTable'[Date])
VAR LatestStatusPerEmployee =
CALCULATETABLE(
SUMMARIZE( /*to summarize by employee ID*/
'FactsTable',
'FactsTable'[EMPLOYEE_EMPLOYEEID],
"LatestStatusChange", MAX('FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP]),
"LatestStatus", CALCULATE(MAX('FactsTable'[EMPLOYMENTSTATUS_LONGNAME]), /*is the column where the status are*/
USERELATIONSHIP('DateDimensionTable'[Date], 'FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP]),
FILTER(ALL('FactsTable'),
'FactsTable'[EMPLOYEE_EMPLOYEEID] = EARLIER('FactsTable'[EMPLOYEE_EMPLOYEEID])
&& 'FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP] == [LatestStatusChange]))
),
USERELATIONSHIP('DateDimensionTable'[Date], 'FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP])
)
VAR CountCondition =
FILTER(
LatestStatusPerEmployee,
[LatestStatus] IN {"Status 1", "status2", "status3"}
)
RETURN
COUNTROWS(CountCondition)
My objective is to create a dynamic headcount measure that tracks employee status changes over time. For instance, using a slicer, if I filter to December 31st, an employee who was in "Status 1" in January and moved to "Status 2" in December should be reflected correctly in the breakdown. However, I'm facing two main issues:
In my model, the primary connection is between the date in my dimension table and the original hire date in the fact table. I've attempted to use a USERELATIONSHIP in the DAX to incorporate a link with the status creation timestamp, but this hasn't resolved the issue.
I'm open to any questions or suggestions for further clarification. Thank you in advance for your help!
@alexflo188 you can try using the following DAX measure:
Headcount Status =
VAR SelectedDate = MAX('DateDimensionTable'[Date])
VAR LatestStatusPerEmployee =
CALCULATETABLE(
SUMMARIZE(
'FactsTable',
'FactsTable'[EMPLOYEE_EMPLOYEEID],
"LatestStatusChange", MAX('FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP]),
"LatestStatus", CALCULATE(MAX('FactsTable'[EMPLOYMENTSTATUS_LONGNAME]),
USERELATIONSHIP('DateDimensionTable'[Date], 'FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP])
)
),
USERELATIONSHIP('DateDimensionTable'[Date], 'FactsTable'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP])
)
VAR CountCondition =
FILTER(
LatestStatusPerEmployee,
[LatestStatus] IN {"Status 1", "status2", "status3"}
)
RETURN
COUNTROWS(CountCondition)
This measure calculates the headcount based on the latest status change for each employee. It also filters the results to only include employees with “Status 1”, “status2”, or “status3”. You can use this measure in a PivotTable to display the headcount by date.
Here are the steps to create a disconnected table:
By using a disconnected table, you can filter the data by date without affecting the overall headcount.
Hello @DallasBaba,
Thanks for you suggestion. That being said, could you explain me why I should use the expression USERELATIONSHIP in the measure if I'm not using the connection from the datedimension table and primary fact table?
Thanks in advance ! 😄
Alex,
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |