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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Miles1987
Frequent Visitor

Active employees in a period

Hi

I have a dax for a KPI that I can’t seem to make work. What I want is to count, the number og employees that has been active every month in the filtered period. The data looks like this:

Miles1987_0-1649065736662.png

 

I figured that I need to know how many months are in the period, I did that this way
V – Number of months= CALCULATE(DISTINCTCOUNT('HRPM SKF'[ID]), ALLEXCEPT('HRPM SKF','HRPM SKF'[EOM]))

This work fine, but I can’t make a dax that counts how many employees that has been active every month in the filtered period.

I tried with:

V – Number of employees  =

Var months = V – Number of months

Var number = DISTINCTCOUNT('HRPM SKF'[Medarbejdernr-W (HRPM)])

 

Return

if(number=moths,1,0)

 

This works fine, when I do a list with employee IDs in it. But not when I aggregate in a KPI.
Jesper

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I suggest having a dim-calendar table like below.

 

Picture1.png

 

Active employee count: = 
VAR employeetable =
    ADDCOLUMNS (
        VALUES ( Data[ID] ),
        "@startdate", CALCULATE ( MIN ( Data[EOM] ) ),
        "@enddate", CALCULATE ( MAX ( Data[EOM] ) )
    )
RETURN
        COUNTROWS (
            FILTER (
                employeetable,
                [@startdate] <= MAX ( 'Calendar'[Date] )
                    && [@enddate] >= MIN ( 'Calendar'[Date] )
            )
        )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I suggest having a dim-calendar table like below.

 

Picture1.png

 

Active employee count: = 
VAR employeetable =
    ADDCOLUMNS (
        VALUES ( Data[ID] ),
        "@startdate", CALCULATE ( MIN ( Data[EOM] ) ),
        "@enddate", CALCULATE ( MAX ( Data[EOM] ) )
    )
RETURN
        COUNTROWS (
            FILTER (
                employeetable,
                [@startdate] <= MAX ( 'Calendar'[Date] )
                    && [@enddate] >= MIN ( 'Calendar'[Date] )
            )
        )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
tamerj1
Super User
Super User

Hi @Miles1987 

did you try simple DISTINCTCOUNT?

Number Of Employees =

DISTINCTCOUNT('HRPM SKF'[ID])

Yes. however i only wanna count them if they have been active every month in the periode.  Lets say i set my period filter to "From 30-06-2021 to 31-07-2021" then it should 2. Because only James and Ivan have been acticve in both months  

@Miles1987 

Then you just need to create new measure

Number Of Employees =

DISTINCTCOUNT('HRPM SKF'[ID])

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.