Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
65 | |
62 | |
51 | |
36 | |
35 |
User | Count |
---|---|
79 | |
66 | |
59 | |
45 | |
45 |