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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
KeyFMSPM
New Member

Needing help with New measure using date range

I struggle with DAX big time and I've been struggling with trying to create a new measure that establishes the number of active users based on a "Hire date" and "Termination date".  What DAX function can I use to find active employee count  if I only have hire and term dates?   I am assuming that once I have this measure, I can use a slicer, for a specific period in time, and have an accurate headcount on said date.  Any help is appreciated.

 

KeyFMSPM_0-1666981314483.png

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @KeyFMSPM 

 

You can try the following methods.
Sample data:

vzhangti_0-1667184929094.png

Create a new calendar table.

Date = CALENDAR(MIN('Table'[Hire date]),TODAY())

Measure:

Measure = 
CALCULATE (
    COUNT ( 'Table'[Employee] ),
    FILTER ( ALL ( 'Table' ), [Termination date] = BLANK () )
)
    + CALCULATE (
        COUNT ( 'Table'[Employee] ),
        FILTER (
            ALL ( 'Table' ),
            [Hire date] >= MIN ( 'Date'[Date] )
                && [Termination date] <= MAX ( 'Date'[Date] )
                && [Termination date] <> BLANK ()
        )
    )

vzhangti_2-1667185019297.pngvzhangti_1-1667185005309.png

Please refer to the attachment.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
KeyFMSPM
New Member

This did the trick!  Thank you.

v-zhangti
Community Support
Community Support

Hi, @KeyFMSPM 

 

You can try the following methods.
Sample data:

vzhangti_0-1667184929094.png

Create a new calendar table.

Date = CALENDAR(MIN('Table'[Hire date]),TODAY())

Measure:

Measure = 
CALCULATE (
    COUNT ( 'Table'[Employee] ),
    FILTER ( ALL ( 'Table' ), [Termination date] = BLANK () )
)
    + CALCULATE (
        COUNT ( 'Table'[Employee] ),
        FILTER (
            ALL ( 'Table' ),
            [Hire date] >= MIN ( 'Date'[Date] )
                && [Termination date] <= MAX ( 'Date'[Date] )
                && [Termination date] <> BLANK ()
        )
    )

vzhangti_2-1667185019297.pngvzhangti_1-1667185005309.png

Please refer to the attachment.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

daXtreme
Solution Sage
Solution Sage

Hi @KeyFMSPM 

 

There are myriads of questions on this forum related to your problem or even straight answers to it. There's a Search box in the upper right corner of the page. Please make use of it. On top of that, I'd strongly suggest that you read this first: How to Get Your Question Answered Quickly - Microsoft Power BI Community

 

It will seriously help you obtain good and quick solutions.

amitchandak
Super User
Super User

@KeyFMSPM , refer to my blog or video. Check the attached files

 

Power BI: HR Analytics - Employees as on Date: https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.