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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tc97
Frequent Visitor

Measure: Rolling Active Users

Hi, 

 

I have a data table tracking employees internal moves between departments. 

 

 

NameDepartmentStart DateEnd Date
[Employee Name][Department Name][First Day in Department][Last Day in Department - NULL IF ACTIVE]

 

I'm now trying to create a measure to give me the average number of people working in a department at any given date (so that it'll work at date, month, and year level). Essentially this should just be a count of any record where the start date is less than or equal to the date, AND the end date is more than the date OR null.

 

I have a calendar table, but haven't created a relationship with this one yet as I'm unsure how to do this as I want to consider both Date columns in the calculation. 

 

Is this something that's easily achievable?

 

Thanks,

Toby

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please try the below measure.

Create a table visualization, and add one of columns from a calendar table (year, month, week, or date column).

And then add the below measure into the table visualization.

 

 

Employees count measure: =
CALCULATE (
    COUNTROWS ( VALUES ( Table[Name] ) ),
    FILTER (
        Table,
        Table[Start Date] <= MAX ( Calendar[Date] )
            && OR ( Table[End Date] >= MIN ( Calendar[Date] ), Table[End Date] = BLANK () )
    )
)

 

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.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please try the below measure.

Create a table visualization, and add one of columns from a calendar table (year, month, week, or date column).

And then add the below measure into the table visualization.

 

 

Employees count measure: =
CALCULATE (
    COUNTROWS ( VALUES ( Table[Name] ) ),
    FILTER (
        Table,
        Table[Start Date] <= MAX ( Calendar[Date] )
            && OR ( Table[End Date] >= MIN ( Calendar[Date] ), Table[End Date] = BLANK () )
    )
)

 

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.


Go to My LinkedIn Page


Thanks so much! Exactly what I needed.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.