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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Juramirez
Resolver I
Resolver I

Calculate rate of employees hired/fired

Hi all,

 

I've a database wich have the employee ID and month. I want to get the count of the new Employee ID by month against previous month (hired employees) and the count of Employee ID that aren't in the month against previous month (fired employees). 

In this link is the excel and the table I'm expecting. I've tried this but the results aren't what I want. 

Any help is appreciated.

 

Regards,

J.

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Juramirez,

 

You can try to use below measures if they suitable for your requirement:

Hire =
VAR currDate =
    MAX ( Sheet1[Date] )
VAR currList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date] >= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 )
                        - 1
        )
    )
VAR prevList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ) - 1
        )
    )
RETURN
    COUNTROWS ( EXCEPT ( currList, prevList ) )
        + IF ( DISTINCTCOUNT ( Sheet1[EmployeeID] ) <> 0, 0, BLANK () )


Fired = 
VAR currDate =
    MAX ( Sheet1[Date] )
VAR currList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date] >= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 )
                        - 1
        )
    )
VAR prevList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ) - 1
        )
    )
RETURN
    COUNTROWS ( EXCEPT ( prevList, currList ) )
        + IF ( DISTINCTCOUNT ( Sheet1[EmployeeID] ) <> 0, 0, BLANK () )

3.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Juramirez,

 

You can try to use below measures if they suitable for your requirement:

Hire =
VAR currDate =
    MAX ( Sheet1[Date] )
VAR currList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date] >= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 )
                        - 1
        )
    )
VAR prevList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ) - 1
        )
    )
RETURN
    COUNTROWS ( EXCEPT ( currList, prevList ) )
        + IF ( DISTINCTCOUNT ( Sheet1[EmployeeID] ) <> 0, 0, BLANK () )


Fired = 
VAR currDate =
    MAX ( Sheet1[Date] )
VAR currList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date] >= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 )
                        - 1
        )
    )
VAR prevList =
    CALCULATETABLE (
        VALUES ( Sheet1[EmployeeID] ),
        FILTER (
            ALLSELECTED ( Sheet1 ),
            [Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, 1 )
                && [Date]
                    <= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ) - 1
        )
    )
RETURN
    COUNTROWS ( EXCEPT ( prevList, currList ) )
        + IF ( DISTINCTCOUNT ( Sheet1[EmployeeID] ) <> 0, 0, BLANK () )

3.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@v-shex-msft are you able to help me figure out this same measure except that I need the fired listed on the month they were fired rather than in the next month? 

Hi  @@v-shex-msf. What an explanation! Really appreciate you take your time to think about my question and give me an answer!

Thanks for sharing your knowledge with us!

 

Regards,

Julián.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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