Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
I am trying to find a way of calculating the amount of consecutive days employees where absent for sickeness, including weekends.
Thank you in advance for your help.
Date | Nom du jour | n° d'employé A | Nom Prénom | Absence 1 | Durée 1 | Consecutive absent | Consecutive absence - 2 days |
21.01.2023 | samedi | 01 | Adeline XXX | 0 | |||
22.01.2023 | dimanche | 01 | Adeline XXX | 0 | |||
23.01.2023 | lundi | 01 | Adeline XXX | 0 | |||
24.01.2023 | mardi | 01 | Adeline XXX | 0 | |||
25.01.2023 | mercredi | 01 | Adeline XXX | 0 | |||
26.01.2023 | jeudi | 01 | Adeline XXX | 0 | |||
27.01.2023 | vendredi | 01 | Adeline XXX | 0 | |||
28.01.2023 | samedi | 01 | Adeline XXX | 0 | |||
29.01.2023 | dimanche | 01 | Adeline XXX | 0 | |||
30.01.2023 | lundi | 01 | Adeline XXX | Maladie | 8 | 1 | 0 |
31.01.2023 | mardi | 01 | Adeline XXX | Maladie | 8 | 2 | 0 |
01.02.2023 | mercredi | 01 | Adeline XXX | Maladie | 8 | 3 | 1 |
02.02.2023 | jeudi | 01 | Adeline XXX | Maladie | 8 | 4 | 2 |
03.02.2023 | vendredi | 01 | Adeline XXX | Maladie | 8 | 5 | 3 |
04.02.2023 | samedi | 01 | Adeline XXX | Maladie | 0 | 6 | 4 |
05.02.2023 | dimanche | 01 | Adeline XXX | Maladie | 0 | 7 | 5 |
06.02.2023 | lundi | 01 | Adeline XXX | Maladie | 8 | 8 | 6 |
07.02.2023 | mardi | 01 | Adeline XXX | Maladie | 8 | 9 | 7 |
08.02.2023 | mercredi | 01 | Adeline XXX | Maladie | 8 | 10 | 8 |
09.02.2023 | jeudi | 01 | Adeline XXX | 0 | |||
10.02.2023 | vendredi | 01 | Adeline XXX | 0 | |||
11.02.2023 | samedi | 01 | Adeline XXX | 0 | |||
21.01.2023 | samedi | 02 | Jean DE | 0 | |||
22.01.2023 | dimanche | 02 | Jean DE | 0 | |||
23.01.2023 | lundi | 02 | Jean DE | Maladie | 8 | 1 | 0 |
24.01.2023 | mardi | 02 | Jean DE | Maladie | 8 | 2 | 0 |
25.01.2023 | mercredi | 02 | Jean DE | Maladie | 8 | 3 | 1 |
26.01.2023 | jeudi | 02 | Jean DE | Maladie | 8 | 4 | 2 |
27.01.2023 | vendredi | 02 | Jean DE | Maladie | 8 | 5 | 3 |
28.01.2023 | samedi | 02 | Jean DE | 0 | 6 | 4 | |
29.01.2023 | dimanche | 02 | Jean DE | 0 | 7 | 5 | |
30.01.2023 | lundi | 02 | Jean DE | Maladie | 8 | 8 | 6 |
31.01.2023 | mardi | 02 | Jean DE | Maladie | 8 | 9 | 7 |
01.02.2023 | mercredi | 02 | Jean DE | 0 | |||
04.02.2023 | samedi | 02 | Jean DE | 0 | |||
05.02.2023 | dimanche | 02 | Jean DE | 0 | |||
06.02.2023 | lundi | 02 | Jean DE | 0 | |||
07.02.2023 | mardi | 02 | Jean DE | 0 | |||
08.02.2023 | mercredi | 02 | Jean DE | 0 | |||
09.02.2023 | jeudi | 02 | Jean DE | 0 | |||
05.03.2023 | dimanche | 02 | Jean DE | 0 | |||
06.03.2023 | lundi | 02 | Jean DE | Maladie | 8 | 1 | 0 |
07.03.2023 | mardi | 02 | Jean DE | 0 |
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:
Create a calculated column in your table to mark the days where an employee was absent due to sickness. Use the following formula:
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.
Create another calculated column to count the number of consecutive sick days for each employee. Use the following formula:
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.
Create a table visual in Power BI and add the following fields to it:
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.
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?
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 > 0, 2, 0)
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
87 | |
87 | |
87 | |
67 | |
49 |
User | Count |
---|---|
135 | |
113 | |
100 | |
68 | |
67 |