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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Vanivanivani
Frequent Visitor

Count sick leave times

Dear Team,

 

I am currently working on a HR report and I would like to have you help on this issue to caculate the sick leave freqency rate.

 

I have the table of Employee sick leave with start date and end date.

 

For the same employee id, it could have multiple lines. for exemple as follows:

 

Employee IDsick leave start datesick leave end date
12305/13/202005/14/2020
12305/15/202005/17/2020
12306/13/202006/15/2020

 

What I would have as result is

for this employee id 123, he/she has 2 times sick leave, because the 1st time then end date is just the day before the 2nd line start date ( so non stop). 

 

Thank you very much.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Vanivanivani , refer ot my blog on similar topic , see if that can help

https://community.powerbi.com/t5/Community-Blog/Power-BI-Continuous-Streak-With-One-Day-Break/ba-p/1...

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

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

 

 

Screenshot 2021-06-21 225108.png

Screenshot 2021-06-21 225821.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Jihwan_Kim
Super User
Super User

 

Picture1.png

 

Sickleave Flag : =
IF (
COUNTROWS (
FILTER (
Data,
MAX ( Dates[Date] ) >= Data[sick leave start date]
&& MIN ( Dates[Date] ) <= Data[sick leave end date]
)
) > 0,
0,
1
)
 
 
Sickleave Flag Cumulate : =
CALCULATE (
SUMX ( VALUES ( Dates[Date] ), [Sickleave Flag :] ),
FILTER ( ALL ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
)
 
 
How many times nonstop sickleaves? : =
VAR newtable =
SUMMARIZE (
FILTER (
ADDCOLUMNS (
VALUES ( Dates[Date] ),
"@cumulateresult", [Sickleave Flag Cumulate :],
"@previousdatecumulateresult", CALCULATE ( [Sickleave Flag Cumulate :], DATEADD ( Dates[Date], -1, DAY ) )
),
[@cumulateresult] = [@previousdatecumulateresult]
),
[@cumulateresult]
)
RETURN
IF ( ISFILTERED ( Employees[Employee ID] ), COUNTROWS ( newtable ) )
 
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

amitchandak
Super User
Super User

@Vanivanivani , refer ot my blog on similar topic , see if that can help

https://community.powerbi.com/t5/Community-Blog/Power-BI-Continuous-Streak-With-One-Day-Break/ba-p/1...

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

Hi there,

Thanks for the solution. May I just add one more question related?

How to count in the weekends? 

For example, 

Employee IDSick leave Start dateSick leave End date
123July 05 2021July 09 2021
123July 12 2021July 16 2021

 

Actually July 10 and 11 are weekend, so for this employee, his/her sick leave time is once.

 

Could you please kindly help to sort out this matter?

Thank you in adavance

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.