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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Over flow of hours to next month

I have a table of H&S incidents with lost time hours due to these incidents:

Incident#DateStaffLost Time Hours
110/03/2020A2
212/06/2020B240
31/07/2020C3
424/08/2020D15

I would like to summarize/visualize Lost Time Hours by Month. The challenge I am having is an incident may have more Lost Time Hours than the number of working hours (assume 160 hours) per staff, per month. I would like the exceeding hours to be overflowed to the next month (and the next etc.)

 

Is there any way to do this in DAX or in Power BI in general? The result I am expecting is similar to below:

YearMonthLost Time HoursComment
2020032 
2020040 
2020050 
202006160Maximum of 160 working hours in a month
202007833hrs + 80 hrs from previous month
20200815 

The limit of 160 hours is per staff member, so if there are 2 incidents involving 2 different staff members in that month the limit should be based on each of the staff member.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous

This is a recursive calculation and can't be expressed simply as a sum/product of some terms since it entails the MAX function. You can't do it with DAX alone. You have to perform this calculation in Power Query. So, for each staff member and each month you have to calculate the hours. Such a table with 3 columns (StaffID, MonthID, Hours) will then be imported into PowerBI and joined to 2 dimensions (Staff, Dates). Then you'll be able to calculate what you need via a measure. Bear in mind that you'll have to deal with granularity issues properly since the table you'll create will have the date granularity of month, whereas your Dates table will be on the day granularity.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Anonymous

This is a recursive calculation and can't be expressed simply as a sum/product of some terms since it entails the MAX function. You can't do it with DAX alone. You have to perform this calculation in Power Query. So, for each staff member and each month you have to calculate the hours. Such a table with 3 columns (StaffID, MonthID, Hours) will then be imported into PowerBI and joined to 2 dimensions (Staff, Dates). Then you'll be able to calculate what you need via a measure. Bear in mind that you'll have to deal with granularity issues properly since the table you'll create will have the date granularity of month, whereas your Dates table will be on the day granularity.
amitchandak
Super User
Super User

@Anonymous , Join with date table and you can have month year here and try a formula like this

 

sumx(summarize(Table, Date[month year], table[Staff], "_1",sum(Table[Lost Time Hours])),if([_1] >160,160,[_1]))

 

For date format refer

https://community.powerbi.com/t5/Desktop/How-to-apply-UK-date-format-dd-mm-yyyy-in-Date-slicer/td-p/599712

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandakthanks but I require the additional hours to be overflowed to the next month?

@Anonymous , Try like 

sumx(summarize(Table, Date[month year], table[Staff], "_1",sum(Table[Lost Time Hours]), "_2",calculate(sum(Table[Lost Time Hours]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))),if([_1] >160,160,[_1])+ if([_2] >160,[_2]-160,0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Just to point out that the date is in dd/MM/yyyy format. Staff Members are A, B, C and D.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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