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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
JCatNR
Frequent Visitor

Finding overlapping dates and changing them to the new Earliest and Latest range.

Hello!

I have a data table that has Order ID, Customer ID, Type, Valid(T/F), Start Date, and End Date. There is already a DAX formula I have created that checks if a customer has an order where the start and end date of one of the order overlaps with another order for the same customer, it populates the DAX column to the earliest start date and the latest end date. If an order has no overlap, the start and end date stay the same.

 

This works fine for basic overlapping orders or orders that are totally within another order, but an issue arises if there are 3 or more overlapping orders that are spread out. Here is an example of the issue:

 Order ID Customer ID Type Valid(T/F) Start Date End DateMin Start DateMax End DateCorrect Start DateCorrect End Date
112T1/1/20251/4/20251/1/20251/7/20251/1/20251/9/2025
212T1/4/20251/7/20251/1/20251/9/20251/1/20251/9/2025
312T1/6/20251/9/20251/4/20251/9/20251/1/20251/9/2025
426T1/1/20251/8/20251/1/20251/8/20251/1/20251/8/2025
526T1/5/20251/7/20251/1/20251/8/20251/1/20251/8/2025
626T1/15/20251/21/20251/15/20251/21/20251/15/20251/21/2025

 

 

JCatNR_0-1738180821685.png

 

 

So as this shows, my current DAX formula works fine for Order 2 since 1 and 3 overlaps it. However, due to Order 3’s start date being after Order 1’s end date, it thinks it’s totally separate.

What I think is needed is a loop that goes through to check if the New Start Date and New End Date changes, the loop goes back through all orders (which would fix the above example after two loops). The occurances of orders overlapping each other could theoretically be infinite, which is why a loop is needed instead of just making a New Start Date2 or something like that.

 

That being said, I am totally open to other suggestions. After doing some research, it seemed like this may be easier to use a Function in Power Query rather than DAX. But with that comes the next problem of how to populate the New Start/End Dates in Power Query based on the other dates.

 

1 ACCEPTED SOLUTION

6 REPLIES 6
v-saisrao-msft
Community Support
Community Support

Hi @JCatNR,

 

We haven’t heard back from you regarding your issue. If it has been resolved, please mark the helpful response as the solution and give a ‘Kudos’ to assist others. If you still need support, let us know.

 

Thank you

v-saisrao-msft
Community Support
Community Support

Hi @JCatNR,

 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @JCatNR,

I wanted to check if you had the opportunity to review the information provided by @lbendlin . Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

lbendlin
Super User
Super User

No need for any of this.  Use CALENDAR and INTERSECT - that will tell you the number of days two orders overlap by. You can do that across all orders for a customer - with the minimal start date and the maximal end date as one of the CALENDARs and the concatenation of the order intervals as the other (via GENERATE) you can then identify the gaps too.

 

 

Thank you for your reply!

I think that makes sense in theory: create a calendar that has the earliest start date and latest end date for a customer, and compare all those dates to the start and end dates of that customer's orders. Returned dates from the intersect show the days included in all start and end dates. Right?

 

If that is correct, should I be creating this DAX function in the Order table? One for the MIN/Start date value, and another for the MAX/End date? I guess I am a little confused about how/where I should be doing all these calculations.

lbendlin_0-1738269922688.png

 

lbendlin_1-1738270076111.png

 

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.

Top Solution Authors
Top Kudoed Authors