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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
PBInewbie11
New Member

Calculate team capacity based on projects and due dates

Hi everyone,

I'm trying to figure out our team's monthly capacity remaining after taking into account current assigned projects based on due dates. Because I don't know when the project’s hours will be used (just know it has to be before end date) my idea is to take the remaining hours and spread them evenly over the remaining months (remaining months includes current month and end date month). This will allow me to see how much capacity we have remaining for new projects.

My original data looks like this:

projectassigned tostart dateend dateproject hourshours used
project aperson bJan-23Dec-233015
project bperson aApr-23Mar-24205
project cperson cSep-23Aug-245040
project dperson aJan-23Dec-2310075
project eperson bFeb-23Jan-24204



I'm trying to figure out how to end up with something like this:

projectassigned tomonthhours
project aperson bDec-2315
project bperson aDec-233.75
project bperson aJan-243.75
project bperson aFeb-243.75
project bperson aMar-243.75
project cperson cDec-231.11
project cperson cJan-241.11
project cperson cFeb-241.11
project cperson cMar-241.11
project cperson cApr-241.11
project cperson cMay-241.11
project cperson cJun-241.11
project cperson cJul-241.11
project cperson cAug-241.11
project dperson aDec-2325
project eperson bDec-238
project eperson bJan-248



So that I can visually see it like this:

PBInewbie11_0-1702589049124.png

 

I’ve been able to calculate number of months remaining until end date, and also number of hours per month (number of months / remaining hours). But I can’t figure out how to allocate it to those months and then graph it totaled by month. I’d also love to be able to make this a stacked bar chart with each person so I can see how much of the monthly time is attributed to each person. Any help provided will be greatly appreciated, I’m at a loss after a couple of weeks of trying to figure it out.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This M code will generate your desired table

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKijKz0pNLlFIVNJRKkgtKs7PU0gCMr0S83SNjIEMl9RkCMPYAEgYmirF6iA0JSE0gfQ7FhRB1PomAhkmQIYRSBOqnmSEHhAzOLUAosexNB2ixxSkx8QARVMKqkWYrjM0AOkyR7UqFdVPbqlJEMVg7XDnmSjFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [project = _t, #"assigned to" = _t, #"start date" = _t, #"end date" = _t, #"project hours" = _t, #"hours used" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"project", type text}, {"assigned to", type text}, {"start date", type date}, {"end date", type date}, {"project hours", Int64.Type}, {"hours used", Int64.Type}}),
    #"Remaining hours" = Table.AddColumn(#"Changed Type", "Remaining hours", each [project hours] - [hours used], Int64.Type),
    #"Month Span" = Table.AddColumn(#"Remaining hours", "Month Span", each (12 * (Date.Year([end date])-Date.Year(DateTime.Date(DateTime.LocalNow()))))
+ (Date.Month([end date])-Date.Month(DateTime.Date(DateTime.LocalNow())))
+ (if Date.Day(DateTime.Date(DateTime.LocalNow())) > Date.Day([end date]) 
    then -1 
    else 0
  )
+ 2),
    #"Monthly hours" = Table.AddColumn(#"Month Span", "Monthly hours", each [Remaining hours] / [Month Span], type number),
    #"Added Custom" = Table.AddColumn(#"Monthly hours", "Month List", each List.Numbers(
  1,
  [Month Span]
)),
    #"Expanded Month List" = Table.ExpandListColumn(#"Added Custom", "Month List"),
    #"Generate date" = Table.AddColumn(#"Expanded Month List", "Date", each Date.StartOfMonth(Date.AddMonths(DateTime.Date(DateTime.LocalNow()),[Month List]-1)), type date),
    #"Removed Columns" = Table.RemoveColumns(#"Generate date",{"start date", "end date", "project hours", "hours used", "Remaining hours", "Month Span", "Month List"})
in
    #"Removed Columns"

Hope this helps.

Ashish_Mathur_0-1702683599308.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

This M code will generate your desired table

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKijKz0pNLlFIVNJRKkgtKs7PU0gCMr0S83SNjIEMl9RkCMPYAEgYmirF6iA0JSE0gfQ7FhRB1PomAhkmQIYRSBOqnmSEHhAzOLUAosexNB2ixxSkx8QARVMKqkWYrjM0AOkyR7UqFdVPbqlJEMVg7XDnmSjFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [project = _t, #"assigned to" = _t, #"start date" = _t, #"end date" = _t, #"project hours" = _t, #"hours used" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"project", type text}, {"assigned to", type text}, {"start date", type date}, {"end date", type date}, {"project hours", Int64.Type}, {"hours used", Int64.Type}}),
    #"Remaining hours" = Table.AddColumn(#"Changed Type", "Remaining hours", each [project hours] - [hours used], Int64.Type),
    #"Month Span" = Table.AddColumn(#"Remaining hours", "Month Span", each (12 * (Date.Year([end date])-Date.Year(DateTime.Date(DateTime.LocalNow()))))
+ (Date.Month([end date])-Date.Month(DateTime.Date(DateTime.LocalNow())))
+ (if Date.Day(DateTime.Date(DateTime.LocalNow())) > Date.Day([end date]) 
    then -1 
    else 0
  )
+ 2),
    #"Monthly hours" = Table.AddColumn(#"Month Span", "Monthly hours", each [Remaining hours] / [Month Span], type number),
    #"Added Custom" = Table.AddColumn(#"Monthly hours", "Month List", each List.Numbers(
  1,
  [Month Span]
)),
    #"Expanded Month List" = Table.ExpandListColumn(#"Added Custom", "Month List"),
    #"Generate date" = Table.AddColumn(#"Expanded Month List", "Date", each Date.StartOfMonth(Date.AddMonths(DateTime.Date(DateTime.LocalNow()),[Month List]-1)), type date),
    #"Removed Columns" = Table.RemoveColumns(#"Generate date",{"start date", "end date", "project hours", "hours used", "Remaining hours", "Month Span", "Month List"})
in
    #"Removed Columns"

Hope this helps.

Ashish_Mathur_0-1702683599308.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@PBInewbie11 , To me seem like very similar HR Problem of Active employee to between date solution

 

refer

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

Between Dates-  Measure way
Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM

 

refer the files attached

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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