Forum Discussion
UBComma
Helper III
5 years agoIdentifying overlaps in date sequences
I need to find conflicts in date ranges that overlap. In this case I have many "Projects" and many "Resources". A given Project will need a Resource for a stated date range. The date ranges will s...
- 5 years ago
I'm imagining you want a calculated table like this:
Here's the code to generate:
CalcTable = FILTER ( ADDCOLUMNS ( CROSSJOIN ( CALENDAR ( MIN ( 'Resource Allocations'[Start Date] ), MAX ( 'Resource Allocations'[End Date] ) ), VALUES ( 'Resource Allocations'[Resource] ) ), "Count", COUNTROWS ( FILTER ( 'Resource Allocations', 'Resource Allocations'[Resource] = EARLIER ( [Resource] ) && 'Resource Allocations'[Start Date] <= EARLIER ( [Date] ) && 'Resource Allocations'[End Date] >= EARLIER ( [Date] ) ) ) ), [Count] > 1 )
AlexisOlson
Super User
5 years agoI'm imagining you want a calculated table like this:
Here's the code to generate:
CalcTable =
FILTER (
ADDCOLUMNS (
CROSSJOIN (
CALENDAR (
MIN ( 'Resource Allocations'[Start Date] ),
MAX ( 'Resource Allocations'[End Date] )
),
VALUES ( 'Resource Allocations'[Resource] )
),
"Count",
COUNTROWS (
FILTER (
'Resource Allocations',
'Resource Allocations'[Resource] = EARLIER ( [Resource] )
&& 'Resource Allocations'[Start Date] <= EARLIER ( [Date] )
&& 'Resource Allocations'[End Date] >= EARLIER ( [Date] )
)
)
),
[Count] > 1
)
UBComma
Helper III
5 years agoI think that's a brilliant solution. I have it working in my model and I learned a lot! Thank you.