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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JK_PowerBINew
Helper II
Helper II

Total Working Days Lost TD For Open Absences

Hi there,

 

I have a list of absences with start date and end date. Some absences have no end date as they remain open. How can I work out the number of working days lost for these absences to date? I have tried both a TOTALYTD and TOTAL MTD DAX function but it is giving an answer of 1 even for absences which started months ago. I also need the measure to be dynamic in that it will only calculate the working days lost within May, even if absences started in March for example.

 

I am really struggling with the restrictive nature of this data with this report!

 

Thanks.

4 REPLIES 4
v-zhangti
Community Support
Community Support

Hi, @JK_PowerBINew 

 

Can you provide some sample data or simple pbix files? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures.

 

Best Regards,

Community Support Team _Charlotte

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

Whitewater100
Solution Sage
Solution Sage

Hello:

 

Please check link for  solution. I have created the model you need to get at this analysis. Measures include Freq of Absense and Days Absent, excluding weekends. I have used some data I had on students but same thing for employees. Note separate date table and dim table for students/employees. Please mark as solution if this works for you. Thanks!

https://drive.google.com/file/d/1RR_NfZ-39VWfETeQQA-4-pTPd5dLV--K/view?usp=sharing 

 

Whitewater100_0-1653669870076.png

 

tamerj1
Super User
Super User

Hi @JK_PowerBINew 
I don't have enough information but for the given information it seems to me that somehow you need to iterate over the table probably using SUMX while you can use COALESCE to return TODAY ( ) incase the end date is blank. Something like

 

=
SUMX (
    TableName,
    VAR StartDate = TableName[Start Date]
    VAR EndDate =
        COALESCE ( TableName[End Date], TODAY () )
    RETURN
        DATEDIFF ( StartDate, EndDate, DAY )
)

For comulative total you can use

=
CALCULATE (
    SUMX (
        TableName,
        VAR StartDate = TableName[Start Date]
        VAR EndDate =
            COALESCE ( TableName[End Date], TODAY () )
        RETURN
            DATEDIFF ( StartDate, EndDate, DAY )
    ),
    'Date'[Date] <= MAX ( 'Date'[Date] )
)

I hope you have a date table

 

Thank you for this. I will try it out and get back to you. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors