Multiple singe day events grouped as single consecutive day events
I am trying to figure out a way, in Magic ETL, to take multiple single day events and group them when there is break in consecutive days.
Example, if the results show the 1st, 2nd, 3rd, 5th, 6th, 9th, 10th and 11th, I need three results, not 8. I want to see begin and end dates of 1st-3rd, 5th-6th, and 9th-11th.
Any thoughts?
Best Answer
-
Walked through how to do it here:
This is modified from what I previously suggested and doesn't require lag and lead functions. Big thanks to @AustinHarrison for the idea of a more simple way to do this using row numbers!If I solved your problem, please select "yes" above
0
Answers
-
Classic gap and island analysis. Here is an article introducing the topic and how to accomplish what you are trying to do:
An alternative way in MagicETL would be to use a lag function and have some logic that if the previous value is not the current value minus one then that current value must be a new start to an island (the 5th in your example). Similarly you could do a lead function and anytime the future value isn't the current value plus one then it is the start of an island (the 6th in your example).
I think the linked article is the cleanest way to do this in a MySQL dataflow.
If I solved your problem, please select "yes" above
0 -
Thank you @ColemenWilson, but could you expand on the MagicETL method? I've been trying to use the Rank & Window with the previous date (lag), but not able to get to the grouping I'm hoping for. I need to somehow carry a constant down the rows until it sees that the datediff is >1, then a new constant until >1, etc.
0 -
Walked through how to do it here:
This is modified from what I previously suggested and doesn't require lag and lead functions. Big thanks to @AustinHarrison for the idea of a more simple way to do this using row numbers!If I solved your problem, please select "yes" above
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 737 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive