Need Rank to update in non-standard (?) way
I've got customer records with customer GUIDs, record dates, and member status. If the data for a specific customer looks like this:
Date | Status |
---|---|
1/1/2023 | Active |
2/1/2023 | Active |
3/1/2023 | Inactive |
4/1/2023 | Inactive |
5/1/2023 | Active |
6/1/2023 | Active |
7/1/2023 | Active |
I want to get a dense ranking that groups the status together, but if the status changes the ranking would update:
Date | Status | Dense Ranking |
---|---|---|
1/1/2023 | Active | 1 |
2/1/2023 | Active | 1 |
3/1/2023 | Inactive | 2 |
4/1/2023 | Inactive | 2 |
5/1/2023 | Active | 3 |
6/1/2023 | Active | 3 |
7/1/2023 | Active | 3 |
(Ultimately what I need is the date the status changed, i.e.: the January, March, and May dates.)
If I include the status in the partition it ends up grouping all the active together with a rank of 1 rather than reset it when the date changes.
Is what I want possible in Magic ETL? We don't have access to the Python tile, so that, unfortunately, is out.
Best Answer
-
If ultimately what you need is when the status changed, you can use a lag function to check the previous status. If the previous status is different than the current status, then flag that row as when the change occured. If the previous status is null or the same, then flag it as no change.
ETL Overview:- Rank & Window:
2. Add Formula:
3. Output:
If I solved your problem, please select "yes" above
0
Answers
-
If ultimately what you need is when the status changed, you can use a lag function to check the previous status. If the previous status is different than the current status, then flag that row as when the change occured. If the previous status is null or the same, then flag it as no change.
ETL Overview:- Rank & Window:
2. Add Formula:
3. Output:
If I solved your problem, please select "yes" above
0 -
That's a huge help, and solved the immediate problem. Thanks!
That said, I forgot to mention that I'd also like to have a field called StatusChangeDate that, for all of the groupings, would have the earliest date of the grouping:
Date
Status
Dense Ranking
Status Change Date
1/1/2023
Active
1
1/1/2023
2/1/2023
Active
1
1/1/2023
3/1/2023
Inactive
2
3/1/2023
4/1/2023
Inactive
2
3/1/2023
5/1/2023
Active
3
5/1/2023
6/1/2023
Active
3
5/1/2023
7/1/2023
Active
3
5/1/2023
Going forward I'll be implementing something that sets that field as the record is written, but I need to be able to add it to the history if at all possible.
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
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 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