cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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 ID sick leave start date sick leave end date 123 05/13/2020 05/14/2020 123 05/15/2020 05/17/2020 123 06/13/2020 06/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
Super User
4 REPLIES 4
Community Champion

 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!
Super User

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

Go to My LinkedIn Page

Super User
Frequent Visitor

Hi there,

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

How to count in the weekends?

For example,

 Employee ID Sick leave Start date Sick leave End date 123 July 05 2021 July 09 2021 123 July 12 2021 July 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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors