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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

Hi @Anonymous ,

 

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
Anonymous
Not applicable

Hi @Anonymous ,

 

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.

Anonymous
Not applicable

Thanks so much! I really appreciate it.

 

amitchandak
Super User
Super User

@Anonymous , 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-or-end-date/ba-p/1503785

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors