Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowHello Power BI Enthusiasts!
I trust you're all doing wonderfully.
I'm in a bit of a bind with a DAX measure I'm trying to construct in Power BI, and I could really use your collective expertise. My goal is to create a measure that counts unique employee records based on their employee number and filters these counts by their employment status using a related status dimension. This measure is intended to be dynamic, reflecting changes over time, leveraging a unique timestamp that marks each status change for the employees.
Despite my efforts, I'm encountering an issue with duplicates in the data,
Here is the DAX I'm using
Test_Headcount_Dimstatus =
VAR __selecteddate = MAX(Dim_calendar_start[Date])
VAR LatestEmployeeRecord =
SUMMARIZE(
'EMPLOYEES - Ceridian modified',
'EMPLOYEES - Ceridian modified'[EMPLOYEE_EMPLOYEEID],
"LatestTimestamp", MAX('EMPLOYEES - Ceridian modified'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP])
)
VAR FilteredEmployeeRecord =
FILTER(
LatestEmployeeRecord,
[LatestTimestamp] <= __selecteddate
)
RETURN
COUNTROWS(FilteredEmployeeRecord)
Accompanying this post is a snapshot of my model for reference.
I've been grappling with this problem for over a month, and it's quite frustrating. Does anyone have any insights into what might be going wrong? Any suggestions or guidance would be greatly appreciated.
Thank you for taking the time to help!
Hey @alexflo188 ,
Try just going back to your original equation and instead of doing a Countrows for your result do DISTINCTCOUNT('FilteredEmployeeRecord'[EMPLOYEE_EMPLOYEEID])
This won't fix the table that you are making, but it should get your count correct.
Or you could try:
Test_Headcount_Dimstatus =
VAR __selecteddate = MAX(Dim_calendar_start[Date])
VAR LatestEmployeeRecord =
SUMMARIZE(
'EMPLOYEES - Ceridian modified',
'EMPLOYEES - Ceridian modified'[EMPLOYEE_EMPLOYEEID],
"LatestTimestamp", MAX('EMPLOYEES - Ceridian modified'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP])
)
VAR FilteredEmployeeRecord1=
FILTER(
LatestEmployeeRecord,
[LatestTimestamp] <= __selecteddate
)
VAR FilteredEmployeeRecord =
FILTER(
FilteredEmployeeRecord1,
DISTINCT(
[EMPLOYEE_EMPLOYEEID])
)
RETURN
COUNTROWS(FilteredEmployeeRecord)
Hey AlexFlo188,
Try this:
Test_Headcount_Dimstatus 2 =
VAR _SelectedDate = MAX(Dim_calendar_start[Date])
VAR _LatestEmployeeRecord =
SummarizeColumns(
'EMPLOYEES - Ceridian modified'[EMPLOYEE_EMPLOYEEID],
"LatestTimestamp", MAX('EMPLOYEES - Ceridian modified'[EMPLOYEEEMPLOYMENTSTATUS_CREATEDTIMESTAMP])
)
VAR FilteredEmployeeRecord =
FILTER(
_LatestEmployeeRecord,
[LatestTimestamp] <= _SelectedDate
)
VAR _Result =
COUNTROWS(
FilteredEmployeeRecord
)
RETURN
_Result
I have thie error 😞
@d_rohlfs I've read on window fonction and I think that might be somthing that work. However I'm not entirely sure how that works could you help me with this ?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
24 | |
15 | |
13 | |
12 | |
8 |
User | Count |
---|---|
30 | |
22 | |
15 | |
14 | |
14 |