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
- Product Ideas
- 2.1K Ideas Exchange
- Data Connections
- 1.3K Connectors
- 309 Workbench
- 17 Cloud Integrations
- Data & ETL
- 2.3K Magic ETL
- 120 SQL DataFlows
- 666 Datasets
- Visualize & Apps
- 90 App Studio
- 198 Pro-code Components
- 2.6K Charting & Analyzer
- 873 Calculations & Variables (Beast Mode)
- AI & Data science
- 23 Domo AI & AI Chat
- 4 Managing AI
- 18 Jupyter Workspaces
- Automate
- 122 Workflows
- Alerts
- Distribute
- 118 Domo Everywhere
- 284 Reporting
- Manage
- 145 Governance & Security
- 489 APIs
- 11 Add-ins & Plugins
- 13 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 118 Community Announcements
- 5K Archive