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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Count consecutive days with absence including weekend

Hello,

I am trying to find a way of calculating the amount of consecutive days employees where absent for sickeness, including weekends.

  • For Adeline the payrool has put the right information of sickness absence including the weekend but for Jean I don't have this data.
  • How can I get this value including the weekend if there is no value added in the database ? (e.g. if an employee was sick on Friday and is still sick on Monday, we must add the weekend and still continue counting)
  • Next, I would like to add a new column to subtract the first 2 days of each absence period that are not paid by the company.
    The first screenshot shows the data I need to get and the second is my data model (except for the red columns).

Thank you in advance for your help.

JL8034_0-1678267822019.png

DateNom du journ° d'employé ANom PrénomAbsence 1Durée 1Consecutive absentConsecutive absence - 2 days 
21.01.2023samedi01Adeline XXX 0  
22.01.2023dimanche01Adeline XXX 0  
23.01.2023lundi01Adeline XXX 0  
24.01.2023mardi01Adeline XXX 0  
25.01.2023mercredi01Adeline XXX 0  
26.01.2023jeudi01Adeline XXX 0  
27.01.2023vendredi01Adeline XXX 0  
28.01.2023samedi01Adeline XXX 0  
29.01.2023dimanche01Adeline XXX 0  
30.01.2023lundi01Adeline XXXMaladie810
31.01.2023mardi01Adeline XXXMaladie820
01.02.2023mercredi01Adeline XXXMaladie831
02.02.2023jeudi01Adeline XXXMaladie842
03.02.2023vendredi01Adeline XXXMaladie853
04.02.2023samedi01Adeline XXXMaladie064
05.02.2023dimanche01Adeline XXXMaladie075
06.02.2023lundi01Adeline XXXMaladie886
07.02.2023mardi01Adeline XXXMaladie897
08.02.2023mercredi01Adeline XXXMaladie8108
09.02.2023jeudi01Adeline XXX 0  
10.02.2023vendredi01Adeline XXX 0  
11.02.2023samedi01Adeline XXX 0  
21.01.2023samedi02Jean DE 0  
22.01.2023dimanche02Jean DE 0  
23.01.2023lundi02Jean DEMaladie810
24.01.2023mardi02Jean DEMaladie820
25.01.2023mercredi02Jean DEMaladie831
26.01.2023jeudi02Jean DEMaladie842
27.01.2023vendredi02Jean DEMaladie853
28.01.2023samedi02Jean DE 064
29.01.2023dimanche02Jean DE 075
30.01.2023lundi02Jean DEMaladie886
31.01.2023mardi02Jean DEMaladie897
01.02.2023mercredi02Jean DE 0  
04.02.2023samedi02Jean DE 0  
05.02.2023dimanche02Jean DE 0  
06.02.2023lundi02Jean DE 0  
07.02.2023mardi02Jean DE 0  
08.02.2023mercredi02Jean DE 0  
09.02.2023jeudi02Jean DE 0  
05.03.2023dimanche02Jean DE 0  
06.03.2023lundi02Jean DEMaladie810
07.03.2023mardi02Jean DE 0  
3 REPLIES 3
MAwwad
Super User
Super User

Salut

 

To calculate the number of consecutive sick days for each employee, including weekends, and to add 2 days to each period of absence that is not paid by the company, you can follow these steps:

  1. Create a calculated column in your table to mark the days where an employee was absent due to sickness. Use the following formula:

     
    Absence Marker = IF(Table1[Absence 1] = "Maladie", 1, 0)

    This will create a new column named "Absence Marker" that will have a value of 1 if the employee was absent due to sickness on a particular day, and 0 otherwise.

  2. Create another calculated column to count the number of consecutive sick days for each employee. Use the following formula:

     
    Consecutive Sick Days = VAR currentRow = Table1[Date] VAR employeeID = Table1[n° d'employé A] VAR startDate = currentRow - Table1[Consecutive absent] VAR endDate = currentRow VAR weekends = 2 * COUNTROWS( FILTER( CALENDAR(startDate, endDate), WEEKDAY([Date], 2) >= 6 ) ) VAR count = SUMX( FILTER( Table1, Table1[n° d'employé A] = employeeID && Table1[Date] >= startDate && Table1[Date] <= endDate && Table1[Absence Marker] = 1 ), 1 ) RETURN count + weekends + IF(count > 0, 2, 0)

    The formula then returns the count of consecutive sick days plus the number of weekend days plus 2 days if the employee was absent for at least one day.

  3. Create a table visual in Power BI and add the following fields to it:

    • Nom Prénom (Employee name)
    • Date
    • Consecutive Sick Days

    You can then filter the table by employee or date as needed.

Note: The formula assumes that the "Date" column is of type "Date" in your table. If it's not, you may need to adjust the formula accordingly. Also, the formula assumes that weekends are Saturday and Sunday. If your company has a different weekend schedule, you'll need to adjust the formula accordingly.

Anonymous
Not applicable

Hello @MAwwad ,

Do you have an idea ?

Thanks a lot,

Anonymous
Not applicable

Hello @MAwwad ,

 

Thanks for your help.

I tried these calculated columns but didn't get the right result.

I don't have Table1[Consecutive absent] in my data model. what data should I take in this specific case?

 

JL8034_0-1678350898511.png

 

for this person, I should have 10 days consecutive sick days.

 

Consecutive Sick Days = VAR currentRow = Table1[Date] 

VAR employeeID = Table1[n° d'employé A]
VAR startDate = currentRow - Table1[Consecutive absent]
VAR endDate = currentRow
VAR weekends = 2 * COUNTROWS( FILTER( CALENDAR(startDate, endDate), WEEKDAY([Date], 2) >= 6 ) )
VAR count = SUMX( FILTER( Table1, Table1[n° d'employé A]
 = employeeID && Table1[Date] >= startDate && Table1[Date] <= endDate && Table1[Absence Marker] = 1 ), 1 )
RETURN count + weekends + IF(count > 020)

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.