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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
MaggieWang
Frequent Visitor

Count how many months within a year an employee took sick leave

Hi everyone,

In this Employee table, column is a list of ID, columns B and C state the sickness start and end dates. I would like to write a DAX measure that counts how many months the individual took sick leave. If someone had multiple occurrences in the same month, I want to count this person only once, but if the sickness occurred in different month, I want to count this person multiple times, once for each month the sickness occurred. So for example if sickness took place in 3 different months, I want to could this person 3 times.

MaggieWang_0-1611831177259.png

The result I would like to achieve is like the following but is achieved with a DAX measure. I have a Date table listing every day in 2020, the Date table is linked to the Employee table by Sickness Start Date column.

MaggieWang_2-1611831410157.png

Thank you for your help

 

With best wishes

 

Maggie

 

1 ACCEPTED SOLUTION
MaggieWang
Frequent Visitor

I have worked out the following DAX measure which has solved my problem. I am adding it here in case someone else encounters similar issues to mine.
 
Number Of Occurrence =
VAR Occurrence = SUMMARIZE(Employee, 'Date'[Month])
VAR Result = SUMX(Occurrence,1)
RETURN Result

View solution in original post

3 REPLIES 3
MaggieWang
Frequent Visitor

I have worked out the following DAX measure which has solved my problem. I am adding it here in case someone else encounters similar issues to mine.
 
Number Of Occurrence =
VAR Occurrence = SUMMARIZE(Employee, 'Date'[Month])
VAR Result = SUMX(Occurrence,1)
RETURN Result
amitchandak
Super User
Super User

@MaggieWang , refer to my blog or the file attached after signature if they can help

 

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  thank you. I actually had found your blog post from this community while searching for a solution to my current problem. Unfortunately this is not going to help me with my problem. At the momehnt I am not too concerned about the length of individual's sickness, your solution would help if I was. What I am looking for is to use Sickness Start Date to access how frequently (i.e. how many months) an employee took sick leave within given period, say a year.  If an employee had multiple occurrences in the same month, I only want to count this person once, not each occurrence. However if the same person took sick leave in different month, I want to count this person multiple times, once for each month the sickness occurred. Thanks.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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