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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
soumyaiyer
Helper IV
Helper IV

With a list of sick days how to calculate occurrences for each employee

Hello,

 

I have a table with a list of events and event dates for each employee. I would need help how to calculate sick days occurrences for each employee.

 

Workdays are from Monday - Saturday

 The only day excluded for sick is Sunday. 

 

1 occurence = 1 sick day

occurence = 2 sick days (need to include if the employee takes sick leave on Saturday & Monday which would be 2 consecutive days - Sunday not counted)

1 occurence = 3 continous days (need to include if the employee takes sick leave on Friday, Saturday & Monday OR

Saturday, Monday, Tuesday which would be 3 consecutive days - both the scenario Sunday is not counted)

 

Above 3 continous days is considered FMLA - no calucation needed for above 3 days.

 

soumyaiyer_0-1758124169001.png

 

 

 

 

soumyaiyer_1-1758124169144.png

 

 

1 ACCEPTED SOLUTION

Hi @soumyaiyer ,

You can try anothe measure which will count the occurences of sick days

NEW SickOccurrences =
CALCULATE(
COUNTROWS('Attendance Tracker'),
FILTER(
'Attendance Tracker',
'Attendance Tracker'[IsWorkday] = 1 &&
'Attendance Tracker'[SickBlockID] = 1 &&
'Attendance Tracker'[Event Type] = "Sick"
)
)

 Hope this helps!

View solution in original post

16 REPLIES 16
v-sdhruv
Community Support
Community Support

Hi @soumyaiyer ,

I hope the solution provided above assists you in resolving the issue. If you have any additional questions, please feel free to reach out.

Thank You for using Microsoft Community Forum

v-sdhruv
Community Support
Community Support

Hi @soumyaiyer ,
I hope the solution provided above assists you in resolving the issue. If you have any additional questions, please feel free to reach out.We would be  happy to help with any further assistance you may need.
Thank You

v-sdhruv
Community Support
Community Support

Hi @soumyaiyer ,

You can create a column to exclude Sunday

IsWorkday = IF(WEEKDAY('Table'[Event Date], 2) <> 7, 1, 0)

Then another calculated column to identify consecutive blocks

SickBlockID =
VAR CurrentDate = 'Table'[Event Date]
VAR PrevDate = 
    CALCULATE(
        MAX('Table'[Event Date]),
        FILTER(
            'Table',
            'Table'[Agent] = EARLIER('Table'[Agent]) &&
            'Table'[Event Date] < EARLIER('Table'[Event Date])
        )
    )
VAR Gap = DATEDIFF(PrevDate, CurrentDate, DAY)
RETURN
    IF(Gap <= 2, 0, 1)


Finally, a measure to calculate the occurences- 

SickOccurrences =
CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        'Table',
        'Table'[IsWorkday] = 1 &&
        'Table'[SickBlockID] = 1
    )
)


This will fetch the below result-

vsdhruv_0-1758190756878.png

Attached file for reference.

Hope this helps!

@v-sdhruv 

 

Thank you for helping me with this. Just a quick update, the table with the event dates does not have Sunday's included. The table log has only Dates for Monday - Saturday.

 

The above calcuated columns and measure is not showing 3 continous days as an occurance. 

 

Here is the snap shot

 

Screenshot 2025-09-25 150907.png

Hi @soumyaiyer ,

Since you wanted Sundays not to be counted, I created a measure to exclude sundays. But if you wanted it to be included, you can modify the measure:

IsWorkday = IF(WEEKDAY('Table'[Event Date], 2) <> 7, 1, 1)

This will return 1 for all days

Hope this helps! 

Hi @v-sdhruv 

 

Thank you for the quick response, after making the changes for the workday measure.

 

The occurrences are not calculating for all 2 or 3 consecutive days . Please see below. Screenshot 2025-09-26 075843.png

Are there any filters to the page which might be restricting the occurences?

2025-09-29_16-02-32.jpgHi,

 

No there are no filter set for the visual or the page. 

Not sure whether the DATEDIFF and Gap calcuation is causing not to pick the correct number of occurences

 

SickBlockID =
VAR CurrentDate = 'Table'[Event Date]
VAR PrevDate = 
    CALCULATE(
        MAX('Table'[Event Date]),
        FILTER(
            'Table',
            'Table'[Agent] = EARLIER('Table'[Agent]) &&
            'Table'[Event Date] < EARLIER('Table'[Event Date])
        )
    )
VAR Gap = DATEDIFF(PrevDate, CurrentDate, DAY)
RETURN
    IF(Gap <= 2, 0, 1)

 

Hi @soumyaiyer ,

 IF(Gap <= 2, 0, 1)


is only evaluated if  Gap is not blank.

Try : IF(ISBLANK(Gap) || Gap > 2, 1, 0)

Hope this helps!


@v-sdhruv 

 

Thank you, I would need help to filter the event by sick , please advise to modify the measure.

 

NEW SickOccurrences =
CALCULATE(
    COUNTROWS('Attendance Tracker'),
    FILTER(
        'Attendance Tracker',
        'Attendance Tracker'[IsWorkday] = 1 &&
        'Attendance Tracker'[SickBlockID] = 1
    )
)

 

 

===============================================

 

SickBlockID =
VAR CurrentDate = 'Attendance Tracker'[Event Date]
VAR PrevDate =
    CALCULATE(
        MAX('Attendance Tracker'[Event Date]),
        FILTER(
            'Attendance Tracker',
            'Attendance Tracker'[Agent Name.title] = EARLIER('Attendance Tracker'[Agent Name.title]) &&
            'Attendance Tracker'[Event Date] < EARLIER('Attendance Tracker'[Event Date])
        )
    )
VAR Gap = DATEDIFF(PrevDate, CurrentDate, DAY)
RETURN
    IF(ISBLANK(Gap) || Gap > 2, 1, 0)

 

Screenshot 2025-10-03 094826.png

Hi @soumyaiyer ,

You can try anothe measure which will count the occurences of sick days

NEW SickOccurrences =
CALCULATE(
COUNTROWS('Attendance Tracker'),
FILTER(
'Attendance Tracker',
'Attendance Tracker'[IsWorkday] = 1 &&
'Attendance Tracker'[SickBlockID] = 1 &&
'Attendance Tracker'[Event Type] = "Sick"
)
)

 Hope this helps!

@v-sdhruv 

Thank you so much for guiding me and helping me through this. I am learning 🙂 I applied the above measure and the results was same. I scrubbed through the measures created again and added a filter in the SickBlockID column and it worked!! Many thanks again! Have a blessed. I will accept the soultion and reach out if need with any other task. 

'Attendance Tracker'[Event Type] = "Sick"

 

soumyaiyer
Helper IV
Helper IV

soumyaiyer_0-1758127289595.png

 

soumyaiyer
Helper IV
Helper IV

AgentEventEvent DateSupervisor
MiriamSick1/10/2025 12:00:00 AMKimberley
AbigailSick1/10/2025 12:00:00 AMKimberley
DereykaSick1/11/2024 12:00:00 AMDerrick
MiriamSick1/11/2025 12:00:00 AMKimberley
MiriamSick1/13/2025 12:00:00 AMKimberley
JasonSick1/13/2025 12:00:00 AMRobin
JasonSick1/14/2025 12:00:00 AMRobin
AngelaSick1/15/2025 12:00:00 AMRobin
JasonSick1/15/2025 12:00:00 AMRobin
CharronSick1/15/2025 12:00:00 AMKimberley
AngelaSick1/16/2025 12:00:00 AMRobin
CharronSick1/16/2025 12:00:00 AMKimberley
AngelaSick1/17/2025 12:00:00 AMRobin
JianCarloSick1/17/2025 12:00:00 AMKimberley
CharronSick1/17/2025 12:00:00 AMKimberley
JianCarloSick1/18/2025 12:00:00 AMKimberley
BrendaSick1/2/2025 12:00:00 AMRobin
JianCarloSick1/20/2025 12:00:00 AMKimberley
AbigailSick1/22/2024 12:00:00 AMKimberley
DereykaSick1/22/2025 12:00:00 AMDerrick
BrendaSick1/23/2025 12:00:00 AMRobin
AgnesSick1/23/2025 12:00:00 AMArthur
JamieSick1/23/2025 12:00:00 AMArthur
JasonSick1/24/2024 12:00:00 AMRobin
BrendaSick1/24/2025 12:00:00 AMRobin
JamieSick1/24/2025 12:00:00 AMArthur
JasonSick1/25/2024 12:00:00 AMRobin
AngelaSick1/26/2024 12:00:00 AMRobin
JasonSick1/26/2024 12:00:00 AMRobin
KrashaunSick1/27/2025 12:00:00 AMArthur
BrittanySick1/28/2025 12:00:00 AMElaine
NoraSick1/28/2025 12:00:00 AMKimberley
AngelaSick1/29/2024 12:00:00 AMRobin
CharronSick1/29/2024 12:00:00 AMKimberley
NoraSick1/29/2025 12:00:00 AMKimberley
JianCarloSick1/3/2024 12:00:00 AMKimberley
NoraSick1/3/2024 12:00:00 AMKimberley
KristinSick1/3/2025 12:00:00 AMElaine
KatSick1/3/2025 12:00:00 AMRaymond
BrendaSick1/3/2025 12:00:00 AMRobin
CharronSick1/30/2024 12:00:00 AMKimberley
NoraSick1/30/2025 12:00:00 AMKimberley
JianCarloSick1/4/2024 12:00:00 AMKimberley
NoraSick1/4/2024 12:00:00 AMKimberley
DavidSick1/4/2025 12:00:00 AMDerrick
KatSick1/4/2025 12:00:00 AMRaymond
JianCarloSick1/5/2024 12:00:00 AMKimberley
NoraSick1/5/2024 12:00:00 AMKimberley
RonniquaSick1/6/2025 12:00:00 AMDerrick
KatSick1/6/2025 12:00:00 AMRaymond
RonniquaSick1/7/2025 12:00:00 AMDerrick
BrendaSick1/8/2024 12:00:00 AMRobin
RonniquaSick1/8/2025 12:00:00 AMDerrick
DereykaSick1/8/2025 12:00:00 AMDerrick
AbigailSick1/9/2025 12:00:00 AMKimberley
MarielaSick1/9/2025 12:00:00 AMArthur
DereykaSick1/9/2025 12:00:00 AMDerrick
DavidSick10/1/2024 12:00:00 AMDerrick
GwendolynSick10/11/2024 12:00:00 AMKimberley
MarielaSick10/18/2024 12:00:00 AMArthur
DereykaSick10/18/2024 12:00:00 AMDerrick
AleishaSick10/21/2024 12:00:00 AMArthur
DereykaSick10/21/2024 12:00:00 AMDerrick
AleishaSick10/22/2024 12:00:00 AMArthur
DereykaSick10/22/2024 12:00:00 AMDerrick
BrittanySick10/23/2024 12:00:00 AMElaine
AleishaSick10/23/2024 12:00:00 AMArthur
DavidSick10/24/2024 12:00:00 AMDerrick
LaTronikaSick10/28/2024 12:00:00 AMKimberley
JianCarloSick10/30/2024 12:00:00 AMKimberley
RafaelSick10/30/2024 12:00:00 AMRaymond
JianCarloSick10/31/2024 12:00:00 AMKimberley
LaTronikaSick10/31/2024 12:00:00 AMKimberley
RafaelSick10/31/2024 12:00:00 AMRaymond
FBergamaschi
Solution Sage
Solution Sage

We can try to help you but 

Please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even is just a subset of the original tables, must cover your issue or question completely. Alternatively, you can share your .pbix via some cloud service and paste the link here. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

 

Need help uploading data? click here

 

Want faster answers? click here

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors