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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
mrverns
Frequent Visitor

Sick leave visualization (start and end dates)

Hi everyone! I've been trying to solve the following by my own but I'm way too far of it.

 

The thing is: I need to analyze some HR data to know which and how many workers are currently with covid or sick leave.


In the attached file you can find a dataset example without calendar table. Note that there's a historical table, so workers (name and id) can be repeated.

Dictionary:

COLUMNMEANING
nameworker name
idworker id number
startDatefirst day of sick leave
endDatelast day of sick leave
days_sickLeavetotal sick leave's days

 

Expected results:
- A table in which rows shows a list of workers with current sick leave or, in other words, absent. Plus, the amount of days' remaining for each worker to 'come back' and its respective date.
- Show a card with the amount of workers with current sick leave.

 

What I think I have to do (but I couldn't make it):
- Identify the most recent or bigger [endDate] per [id] to know last sick leave period per worker.
- Compare each [endDate] with TODAY() to know current sick leave.
- I also tried to compare TODAY() with [startDate] and [endDate].

 

Attached file: https://www.dropbox.com/s/b344qpway3nb5ac/sickleave.pbix?dl=0

 

As you may note, I'm still with the basics. Thanks in advance!

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

Hi @mrverns ,

 

I didn't use the calendar table.

Firstly, I create a column to get the people on sick leave.

Is on sick leave = IF([startDate]<=TODAY()&&[endDate]>=TODAY(),"Y","N")

Then create another column to get the days' remaining who are on sick leave.

days' remaining = IF([Is on sick leave]="Y",DATEDIFF(TODAY(),[endDate],DAY),BLANK())

vstephenmsft_0-1657789542468.png

 

Current day is 7/14/2022, the result is below.

vstephenmsft_1-1657789568699.png

 

 

Best Regards,

Stephen Tao

 

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

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @mrverns ,

 

I didn't use the calendar table.

Firstly, I create a column to get the people on sick leave.

Is on sick leave = IF([startDate]<=TODAY()&&[endDate]>=TODAY(),"Y","N")

Then create another column to get the days' remaining who are on sick leave.

days' remaining = IF([Is on sick leave]="Y",DATEDIFF(TODAY(),[endDate],DAY),BLANK())

vstephenmsft_0-1657789542468.png

 

Current day is 7/14/2022, the result is below.

vstephenmsft_1-1657789568699.png

 

 

Best Regards,

Stephen Tao

 

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

Thanks so much! I really appreciate it.

 

amitchandak
Super User
Super User

@mrverns , People on sick leave today

 

countrows(filter(Table, Table[Start Date] <= Today() && Table[End Date] >= Today()) )

 

Most Recent leave

Var _Max = maxx(filter(allselected(Table), Table[Start Date] < Today() ), Table[End date]) )

return

maxx(filter(allselected(Table), Table[end Date] =_max ), Table[ID]) )

 

Also, refer

 

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

Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

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

This worked perfectly, even when I visualize it as a table, but with a column showing "1" in every row. Thanks @amitchandak 

 

countrows(filter(Table, Table[Start Date] <= Today() && Table[End Date] >= Today()) )

 

 

About the second code I'm having problems to completely understand it. Can u please explain me how does it work?

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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