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
lucaslopesp
Regular Visitor

How to verify if two range dates clash

I have a database where I can find the following informations: Resource, project, start date and end date. I would like to create a function that is able to check if the resource's projects dates clash. The outcome would be like the Status column bellow:

lucaslopesp_0-1680194292335.png

 

 

The dates follow the formula DD/MM/YYYY

 

If it's not clear, let me know

 

Thank you !

1 REPLY 1
vicky_
Super User
Super User

We can break down the problem into 2 steps - find the start date of the previous and next time a resource is used, and then check if that date lies between the start and end dates of the current entry. 

 

Status = 

var prevTime = CALCULATE(MAX(Table[Start]),
    FILTER('Table', 'Table'[Resource] = EARLIER('Table'[Resource]) &&
        'Table'[Start] < EARLIER('Packing Scan'[Start])
    )
)
var nextTime = CALCULATE(MIN(Table[Start]),
    FILTER('Table', 'Table'[Resource] = EARLIER('Table'[Resource]) &&
        'Table'[Start] > EARLIER('Packing Scan'[Start])
    )
)
return IF(prevTime > [Start] || nextTime < [End], "Check", "OK")
 
You might need to fiddle with the formula (e.g. null checks) but it should help get you started.

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.