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
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

@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
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.