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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

COUNT Number of employees left in this Month(MTD) and this Year(YTD)

I am trying to count the number of employees who left in the Month we are currently we are in as well as the year we are in. Assuming we are in November 2022.   The Data is as follows

Employee Date Left
EMployee1 12/11/2022
Employee2 06/10/2022
Employee3 01/07/2022
Employee4 12/08/2022
Employee5 18/06/2022
Employee6 22/05/2022

 

Only EMployee 1 has left in November 2022 so for the month, it should return 1 , and for the Year count, it should return 6 Employees since all of them left in the year 2022. How do I achieve this?

1 ACCEPTED SOLUTION
vojtechsima
Super User
Super User

Hi, @Anonymous 
Like this:

vojtechsima_0-1668543921777.png

Employee Left MTD = 
CALCULATE(
    COUNTROWS('Table'),
    DATESMTD('Table'[Date Left])
)
Employee Left YTD = 
CALCULATE(
    COUNTROWS('Table'),
    DATESYTD('Table'[Date Left])
)

I assume your table contains one row = one employee, and for the column for DATESYTD/MTD, you should preferably use your Calendar date dolumn.
If this doesn't work add slicer with context filter context, such as month etc.

 

 





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

View solution in original post

2 REPLIES 2
Mikelytics
Resident Rockstar
Resident Rockstar

 

 

Hi  @Anonymous ,

 

Please try the following measure (I assume you also use a separate date table?):

 

 

 

Number of Employees Left =

CALCULATE(
   COUNTROWS(Table),
   FILTER(
      Table,
      Table[Date Left] <= MAX(Date[Date])
   )
)

 

 

 

If this does not work some questions.

 

Can you please put it in a visual and use a slicer like you described in your request to show which values do not meet your expectation?

 

Are in your table also employees who did not leave?

 

Is in the table each row one employee or are there some other relevant columns regarding

 

Are there other Measures you use in combination with this one?

 

Best regards

Michael

-----------------------------------------------------

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

@ me in replies or I'll lose your thread.

 

 granularity?

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
vojtechsima
Super User
Super User

Hi, @Anonymous 
Like this:

vojtechsima_0-1668543921777.png

Employee Left MTD = 
CALCULATE(
    COUNTROWS('Table'),
    DATESMTD('Table'[Date Left])
)
Employee Left YTD = 
CALCULATE(
    COUNTROWS('Table'),
    DATESYTD('Table'[Date Left])
)

I assume your table contains one row = one employee, and for the column for DATESYTD/MTD, you should preferably use your Calendar date dolumn.
If this doesn't work add slicer with context filter context, such as month etc.

 

 





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.