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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Absenteeism - Calculating Total Working Days Lost when End Date of Absence Not Known

Hi there,

 

I am creating a monthly absence report and just now are restricted to only calculating the total working days lost for absences which are closed (i.e., have an end date). I would like to also be able to calculate the total working days lost till date for those absences which are still ongoing (no end date) in that month.

 

My logic so far for the measure, is to count 1 working day lost for each date within the Absence Start Date and Absence End Date Range or count 1 working day lost for each date from the Absence Start Date until today if the end date is empty and then iterate through this count to sum the total working days lost but I am struggling to come up with the correct measure for this if anyone can help.

 

Here is a simple sample data structure:

 

RoleStart Date of AbsenceEnd Date of Absence
Accountant15/07/2219/07/22
HR Manager14/07/22 
Data Analyst01/07/2211/07/22
Service Desk Analyst20/07/22 

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to try this code to create a measure.

Measure = 
VAR _CALENDAR =ADDCOLUMNS( CALENDARAUTO(),"Weekday",WEEKDAY([Date],2))
VAR _FILTER = FILTER(_CALENDAR,[Date]>= MAX('Table'[Start Date of Absence])&&[Date]<=IF( MAX('Table'[End Date of Absence])=BLANK(),TODAY(),MAX('Table'[End Date of Absence])))
RETURN
COUNTX(FILTER(_FILTER,NOT( [Weekday] IN {6,7})),[Date])

Result is as below.

RicoZhou_0-1658822722426.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

That is really great! It works perfectly in table form. I have used a slight variation of this measure for annual absences too and it works great. Having said that, do you know of a small edit I could make which would allow me to view the total working days lost over the date time-series.

Anonymous
Not applicable

Hi @Anonymous ,

 

I think you can try to create a new measure based on this measure.

Measure with total = SUMX(VALUES('Table'[Role]),[Measure])

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnt75
Super User
Super User

You could try

Work days lost =
VAR minDate =
    MIN ( 'Date'[Date] )
VAR maxDate =
    MAX ( 'Date'[Date] )
RETURN
    SUMX (
        'Absences',
        VAR startDate =
            MAX ( 'Absences'[Start date], minDate )
        VAR endDate =
            MIN ( 'Absences'[End date], maxDate )
        RETURN
            NETWORKDAYS ( startDate, endDate )
    )

That should work with date filters to show days lost in a given month.

Anonymous
Not applicable

Hi John,

 

Thanks so much for this. It appears to work for the absences which have an end date but gives odd values for those which don't:

JK_PowerBINew_0-1658427599401.png

 

Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to try this code to create a measure.

Measure = 
VAR _CALENDAR =ADDCOLUMNS( CALENDARAUTO(),"Weekday",WEEKDAY([Date],2))
VAR _FILTER = FILTER(_CALENDAR,[Date]>= MAX('Table'[Start Date of Absence])&&[Date]<=IF( MAX('Table'[End Date of Absence])=BLANK(),TODAY(),MAX('Table'[End Date of Absence])))
RETURN
COUNTX(FILTER(_FILTER,NOT( [Weekday] IN {6,7})),[Date])

Result is as below.

RicoZhou_0-1658822722426.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.