The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a table which contains employees DateStarted and Leavedates. Leavedates is NULL if they are still active. In SQL I would run a where statement based on SSRS date parameters to only include active in a month period for example,
where (LeaveDate >= @datefrom and DateStarted < @dateto) or (DateStarted < @dateto and LeaveDate is NULL)
so if I replace the parameters with dates
where (LeaveDate >= '01 May 2020' and DateStarted < '01 Jun 2020) or (DateStarted < '01 Jun 2020) and LeaveDate is NULL)
... so this captures anyone who were active for any portion of this month for example, or even start before and finish after etc.
I am struggling to convert this to a measure so I can display a count of employees on a 3D card, based on a date slider linked to a calendar table, making this value dynamic. Thank you in advance.
Solved! Go to Solution.
@Beavertron
Use the following measure to get the active employees to count. Modify the table name and field names as per your model.
Employee Count =
VAR __DATE = MAX ( 'Date'[Date] )
RETURN
SUMX (
EmployeeTable,
IF (
EmployeeTable[DateStarted] <= __DATE
&& OR ( EmployeeTable[Leavedates] >= __DATE , ISBLANK(EmployeeTable[Leavedates]) ),
1,
BLANK ()
)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Beavertron
Use the following measure to get the active employees to count. Modify the table name and field names as per your model.
Employee Count =
VAR __DATE = MAX ( 'Date'[Date] )
RETURN
SUMX (
EmployeeTable,
IF (
EmployeeTable[DateStarted] <= __DATE
&& OR ( EmployeeTable[Leavedates] >= __DATE , ISBLANK(EmployeeTable[Leavedates]) ),
1,
BLANK ()
)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
User | Count |
---|---|
12 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
24 | |
14 | |
14 | |
9 | |
7 |