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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bigrods
Helper II
Helper II

Break-Down Employee Sickness Days Lost with Date Table

Hi,

 

I'm trying to work on a measure that calculates the sum of Days lost due to Employee sickness.

I have created a temporary table in my measure and I also have a seperate Date table (called Calendar)

The issue I'm having is that employee sickness can span across months, and when I select a certain month on the page it returns the total days for the entire sickness, not broken down by how much specifically lost in that month.

On the attached images, if I select April 2024 on the page I get 179 Days - this is the Total Days Lost for all Sickness recorded that began in April, the actual answer should be 20:

4 Days from Assignment No. 30761466 (2nd - 5th April) and 16 Days from Assignment No. 27160971 (began 15th April)

 

In my measure I tried to create a table column that calculates the DATEDIFF for the start and end period of the Calendar table, so I'd hoped this would then calculate the Days Lost accordingly. If anyone could help I would be very grateful!

 

Many thanks!

 

1.png2.png3.png

1 ACCEPTED SOLUTION
v-linhuizh-msft
Community Support
Community Support

Hi @bigrods ,

 

Here is the modified formula:

New Sickness FTE Measure = 
VAR _startperiod =
    MIN ( 'calendar'[Date] )
VAR _endperiod =
    MAX ( 'calendar'[Date] )
VAR _absenttable =
    ADDCOLUMNS (
        FILTER (
            'SummariseAbsences',
            ( [Absence Start Date] >= _startperiod
                && [Absence Start Date] <= _endperiod
                && [Absence End Date] <= _endperiod )
                || ( [Absence Start Date] >= _startperiod
                && [Absence Start Date] < _endperiod
                && [Absence End Date] >= _endperiod )
                || ( [Absence Start Date] < _startperiod
                && [Absence End Date] >= _startperiod
                && [Absence End Date] < _endperiod )
                || ( [Absence Start Date] < _startperiod
                && [Absence End Date] > _endperiod )
        ),
        "_FTEStartDate", 'SummariseAbsences'[Absence Start Date],
        "_FTEEndDate", 'SummariseAbsences'[Absence End Date],
        "_FTESickHours",
            IF (
                'SummariseAbsences'[Absence Start Date] < _startperiod,
                IF (
                    'SummariseAbsences'[Absence End Date] > _endperiod,
                    'SummariseAbsences'[FTE]
                        * ( DATEDIFF ( _startperiod, _endperiod, DAY ) + 1 ),
                    'SummariseAbsences'[FTE]
                        * ( DATEDIFF ( _startperiod, 'SummariseAbsences'[Absence End Date], DAY ) + 1 )
                ),
                IF (
                    'SummariseAbsences'[Absence End Date] > _endperiod,
                    'SummariseAbsences'[FTE]
                        * ( DATEDIFF ( 'SummariseAbsences'[Absence Start Date], _endperiod, DAY ) + 1 ),
                    'SummariseAbsences'[FTE]
                        * (
                            DATEDIFF (
                                'SummariseAbsences'[Absence Start Date],
                                'SummariseAbsences'[Absence End Date],
                                DAY
                            ) + 1
                        )
                )
            )
    ) 
// IF('SummariseAbsences'[Absence Start Date]<=_startperiod,
// IF('SummariseAbsences'[Absence End Date]=DATE(4712,12,31)||'SummariseAbsences'[Absence Start Date]>=_endperiod,'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,_endperiod,DAY)+1),
// 'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,'SummariseAbsences'[Absence End Date],DAY)+1)),
// if('SummariseAbsences'[Absence Start Date]<=_endperiod&&('SummariseAbsences'[Absence End Date]=DATE(4712,12,31)||'SummariseAbsences'[Absence End Date]>=_endperiod),
// 'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,_endperiod,DAY)+1),
// 'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,[Absence End Date],DAY)+1))),
//"_FTEDaysLost",'SummariseAbsences'[Total Days Lost])
VAR _ftedayslost =
    SUMX ( _absenttable, [_FTESickHours] )
RETURN
    _ftedayslost

The logic for calculating the _FTESickHours column is modified, and the variable _ftedayslost is modified to sum _FTESickHours.

 

Result:

vlinhuizhmsft_0-1737085652447.png

Best Regards,
Zhu

 

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

View solution in original post

2 REPLIES 2
v-linhuizh-msft
Community Support
Community Support

Hi @bigrods ,

 

Here is the modified formula:

New Sickness FTE Measure = 
VAR _startperiod =
    MIN ( 'calendar'[Date] )
VAR _endperiod =
    MAX ( 'calendar'[Date] )
VAR _absenttable =
    ADDCOLUMNS (
        FILTER (
            'SummariseAbsences',
            ( [Absence Start Date] >= _startperiod
                && [Absence Start Date] <= _endperiod
                && [Absence End Date] <= _endperiod )
                || ( [Absence Start Date] >= _startperiod
                && [Absence Start Date] < _endperiod
                && [Absence End Date] >= _endperiod )
                || ( [Absence Start Date] < _startperiod
                && [Absence End Date] >= _startperiod
                && [Absence End Date] < _endperiod )
                || ( [Absence Start Date] < _startperiod
                && [Absence End Date] > _endperiod )
        ),
        "_FTEStartDate", 'SummariseAbsences'[Absence Start Date],
        "_FTEEndDate", 'SummariseAbsences'[Absence End Date],
        "_FTESickHours",
            IF (
                'SummariseAbsences'[Absence Start Date] < _startperiod,
                IF (
                    'SummariseAbsences'[Absence End Date] > _endperiod,
                    'SummariseAbsences'[FTE]
                        * ( DATEDIFF ( _startperiod, _endperiod, DAY ) + 1 ),
                    'SummariseAbsences'[FTE]
                        * ( DATEDIFF ( _startperiod, 'SummariseAbsences'[Absence End Date], DAY ) + 1 )
                ),
                IF (
                    'SummariseAbsences'[Absence End Date] > _endperiod,
                    'SummariseAbsences'[FTE]
                        * ( DATEDIFF ( 'SummariseAbsences'[Absence Start Date], _endperiod, DAY ) + 1 ),
                    'SummariseAbsences'[FTE]
                        * (
                            DATEDIFF (
                                'SummariseAbsences'[Absence Start Date],
                                'SummariseAbsences'[Absence End Date],
                                DAY
                            ) + 1
                        )
                )
            )
    ) 
// IF('SummariseAbsences'[Absence Start Date]<=_startperiod,
// IF('SummariseAbsences'[Absence End Date]=DATE(4712,12,31)||'SummariseAbsences'[Absence Start Date]>=_endperiod,'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,_endperiod,DAY)+1),
// 'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,'SummariseAbsences'[Absence End Date],DAY)+1)),
// if('SummariseAbsences'[Absence Start Date]<=_endperiod&&('SummariseAbsences'[Absence End Date]=DATE(4712,12,31)||'SummariseAbsences'[Absence End Date]>=_endperiod),
// 'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,_endperiod,DAY)+1),
// 'SummariseAbsences'[FTE]*(DATEDIFF(_startperiod,[Absence End Date],DAY)+1))),
//"_FTEDaysLost",'SummariseAbsences'[Total Days Lost])
VAR _ftedayslost =
    SUMX ( _absenttable, [_FTESickHours] )
RETURN
    _ftedayslost

The logic for calculating the _FTESickHours column is modified, and the variable _ftedayslost is modified to sum _FTESickHours.

 

Result:

vlinhuizhmsft_0-1737085652447.png

Best Regards,
Zhu

 

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

Thanks so much this has worked!

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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