Overlapping Date Beast Mode

Hi everyone! For context, I am making a card that flags overlapping contract dates. I want to make sure that the first order finishes its duration first before having another order. I only want to partition the overlap flag by customer and by the same business unit. Please see the Excel visualization sample I made below. Can anyone help on my beast mode for the Overlap? Thank you!
Best Answer
-
I approached this using Magic ETL, and here is how I did it:
1. Create a Lead and Lag function to get the previous End Date and the upcoming Start Date.2. Create a formula to flag when there is overlap. (also by creating this I noticed that your data in the excel screenshot for overlap appears wrong. For Customer ABC there is overlap with order number 3 ending 12/30/2025 and order number 4 starting 1/1/2025)
If I solved your problem, please select "yes" above
1
Answers
-
I approached this using Magic ETL, and here is how I did it:
1. Create a Lead and Lag function to get the previous End Date and the upcoming Start Date.2. Create a formula to flag when there is overlap. (also by creating this I noticed that your data in the excel screenshot for overlap appears wrong. For Customer ABC there is overlap with order number 3 ending 12/30/2025 and order number 4 starting 1/1/2025)
If I solved your problem, please select "yes" above
1 -
I think you are getting confused by your data. The answers to your data would not be what you show. Your last record overlaps but your display says it doesn't. I did it using SQL Dataflow.
SELECT
a.order_number,
a.customer,
a.business_unit,
CASE
WHEN a.start_date < b.end_date AND a.end_date > b.start_date THEN 'Yes'
ELSE 'No'
END AS overlap_flag
FROM overlap_test a
JOIN overlap_test b
ON a.customer = b.customer
AND a.business_unit = b.business_unit
AND a.order_number != b.order_number
ORDER BY a.order_number;
But to get the answer you show, I had to change the record date on the last record so it wouldn't overlap.customer
order_number
business_unit
start_date
end_date
xyz
1
BU1
1/1/2023
12/31/2024
xyz
2
BU1
12/29/2024
12/30/2025
abc
3
BU2
12/29/2024
12/30/2025
abc
4
BU2
1/1/2026
12/31/2026
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 656 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 813 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 81 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive