I am struggling with a formula for the Occupation of Resources per Month.
Occupied Days WithIn Month =
VAR StartDate = VALUE( SELECTEDVALUE( 'Resource Assignments'[Start] ) )
VAR FinishDate = VALUE( SELECTEDVALUE( 'Resource Assignments'[Finish] ) )
VAR MinDateInContext = VALUE( MIN( 'Calendar'[Date] ) )
VAR MaxDateInContext = VALUE( MAX( 'Calendar'[Date] ) )
IF( AND( StartDate < MinDateInContext, FinishDate > MinDateInContext ) ,
MIN( FinishDate, MaxDateInContext ) - MinDateInContext,
IF( AND( AND( StartDate > MinDateInContext, StartDate < MaxDateInContext ), FinishDate > MinDateInContext ),
MIN( FinishDate, MaxDateInContext ) - StartDate,
BLANK() ) )
This basically gives me the right thing, I only need to add something to finalize it. My Matrix visual looks like this:
*All numbers of days and dates are used as examples
Resource - Jan 23 - Feb 23 - Mar 23
Resource A 5 days
Resource B 10 days
Problem A) is this formula doesn't calculate the SUM of Occupation Days per Resource, so when a Resource works on task 1 for the first 5 days of January and also works on task 2 the last 5 days of January, the formula gives 5 Occupation days, but ofcourse I need 10.
Problem B) is that this formula doesn't work when a Resource works on task 1 the last 10 days of January until the 10th day of February. In this case the formula should give 10 Occupation days in Jan and also 10 in Feb (in the Matrix visual), but instead the formula gives the 10 of Jan and skips the 10 in Feb as a whole.
Hopefully you can grasp my situation here. If not clear, I will come back with a sample file.