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
- 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
- 738 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