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
Rune
Frequent Visitor

Sick leave dashboard

Hi, 

As I am quite new to Power BI and Power query any help is greatly appreciated! 


I have two main question that I want answered for my Sick Leave Dashboard.

1. How many hours (working hours) of sick leave do we have each month?
For this one it is important that I can allocate working hours to the right month based on an entry (keeping in mind that weekends exist).
2. How many people have been sick each month?
For this one it is important that Hans is counted as 1 for every individual month (January to June) and not just for the starting month. I want to be able to have a count for each month throughout the year.


This is what my data set looks like

Person/date of entryStart DateEnd DateTotal amount of working hours
Greta-entrydate25/03/201904/04/201960
Hans-entrydate02/01/201927/06/2019735


Thanks in advance!

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

Hi @Rune ,

 

For question 1:

 

1.Create a calendar table using below dax expression:

 

Table 2 = CALENDARAUTO()

 

Then create a column to get the weekday of each day:

 

column = WEEKDAY('Table 2'[Date],2)

 

After that,create a measure below:

 

Sick hours = 
var a= COUNTROWS((FILTER('Table 2','Table 2'[Date]>=CALCULATE(MIN('Table'[Start Date]),ALLEXCEPT('Table','Table'[Person/date of entry]))&&'Table 2'[Date]<=CALCULATE(MAX('Table'[End Date]),ALLEXCEPT('Table','Table'[Person/date of entry]))&&'Table 2'[column]<6)))
Return
a*8-SELECTEDVALUE('Table'[Total amount of working hours])

 

Finally you will see:

Annotation 2020-03-30 152909.png

 

As for question 2,can you provide more details that how to define which month does the sick hours take?For example:Greta has asked for 12hours as sick leave,but how to define whether the 12 hours  happen in March or April?

 

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @Rune ,

 

For question 1:

 

1.Create a calendar table using below dax expression:

 

Table 2 = CALENDARAUTO()

 

Then create a column to get the weekday of each day:

 

column = WEEKDAY('Table 2'[Date],2)

 

After that,create a measure below:

 

Sick hours = 
var a= COUNTROWS((FILTER('Table 2','Table 2'[Date]>=CALCULATE(MIN('Table'[Start Date]),ALLEXCEPT('Table','Table'[Person/date of entry]))&&'Table 2'[Date]<=CALCULATE(MAX('Table'[End Date]),ALLEXCEPT('Table','Table'[Person/date of entry]))&&'Table 2'[column]<6)))
Return
a*8-SELECTEDVALUE('Table'[Total amount of working hours])

 

Finally you will see:

Annotation 2020-03-30 152909.png

 

As for question 2,can you provide more details that how to define which month does the sick hours take?For example:Greta has asked for 12hours as sick leave,but how to define whether the 12 hours  happen in March or April?

 

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
amitchandak
Super User
Super User

This measure you can plot with dates to know dates of leave

CALCULATE(countx(SUMMARIZE(filter(CROSSJOIN('Table','DimDate'),'DimDate'[Date] >= 'Table'[AbsenceStartDate] && 'DimDate'[Date]<= 'Table'[AbsenceEndDate]),'Table'[id],'DimDate'[Date]),'DimDate'[Date]))

 

Or refer to this solution

https://www.dropbox.com/s/1c3eg4y52d49uel/Leave%20test%20data.pbix?dl=0

 

You can multiply no of Hours with days

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.