Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

Counting Current Staff - DAX not correct

Hi there

 

I'm trying to return the count of staff that are employed on any given day/month/year. Table1 contains the staffID, StartDate and TerminatedDAte. Table2 is a date dimension.  The current count is returning basically no results for all dates in 2018. Where have i gone wrong? 

I want to be able to return '### staff were employed on 22/01/2018' or month on month active employee counts.

 

Count of Active Employees =
VAR currentdate =
    MAX( 'Table2'[Date])
RETURN
    CALCULATE(
        [Staff ID Count],
        FILTER (
            Table1,
            (Table1[StaffStartDate] <= currentDate
                && Table1[StaffTerminationDate] >= currentDate )
        ))

4 REPLIES 4
Anonymous
Not applicable

Hi,

 

How does the TerminatedDate look for staff still working? Do you account for blanks?

 

This might work in such a case:

CountStaff.PNG

Anonymous
Not applicable

Thanks Ahrne, i think you're onto something. I have not handled the blanks in the terminated date column. 

When taking on your query, i'm getting the following error. 
 
 
The syntax for ';' is incorrect.
(DAX
(
VAR currentdate = MAX('Date'[Date])
VAR staffCount =
CALCULATE(
COUNTROWS(Dim_Staff);Dim_Staff[StaffTerminationDate]>currentdate) +
CALCULATE(
COUNTBLANK(Dim_Staff[StaffTerminationDate]);Dim_Staff[StaffStartDate] < currentdate)
RETURN staffCount
 
Anonymous
Not applicable

Logic may need rework. What if someone's termination date was about a week ago and the currentdate is today. He will be counted as an active employee because you are filtering the table to allow any entries below the current date.

DaFloDo
Resolver I
Resolver I

Hi @Anonymous,

 

i think there coud be a current filter context on Table1. So you could try applying your time yondition to All(Talbe1).

 

best regards

 

florian

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.