Leap year in Magic ETL
Hi all,
I'm working on an dataflow (Magic ETL) through which I calculate the MTD, QTD & YTD metrics for both This Year and Last Year data so that I compare the values for each one of these metrics. According to Finance, for leap years, when This Year the last day of Feb is the 28th and Last Year was the 29th, this extra day should be included in the metrics above.
I have created a flow of various steps which end up in 4 'if cases' (filters excluding one another) based on the following logic:
1. This Year (TY) is not 28/Feb or 29/Feb thus Last Year (LY) equals to same date last year, eg. TY=25/3/2019 -> LY=25/3/2018
2. TY = 28th Feb & LY = 28th Feb thus LY equals to same date last year, eg. TY=28/2/2019 -> LY=28/2/2018
3. TY = 28th Feb & LY = 29th Feb thus LY equals to same date last year plus 1, eg. TY=28/2/2021 -> LY=29/2/2020
4. TY = 29th Feb thus LY equals to same date last year minus 1, eg. TY=29/2/2020 -> LY=28/2/2019
The 4 filters along with the preceding steps take a significant amount of time to refresh especially when it comes to large input datasets. I was wondering if anyone else has used a similar logic on leap years in an ETL as I try to find a lighter approach. In my case, this part of the flow is to ensure I don't exclude the 29th of Feb in the MTD, QTD & YTD metrics and compare TY & LY data accurately.
Comments
-
Hey Effie,
I think the best way to handle leap year would be to use Domo's Calendar card type. That will already account for leap year and everything else that might be needed in that regard. Outside of a Calendar card, I would suggest ensuring that your source data accounts for this change.
Jarvis
0 -
Hi, @Effie ,
Since you want to do this in MagicETL, you might consider creating CY/PY calendar before hand, and then referencing that table in your dataflow. You CY/PY calendar might look something like this:
Date | PY Date
---------------------------
2017-02-28 | 2016-02-28
2017-02-27 | 2016-02-27
...
2016-03-01 | 2015-03-01
2016-02-29 | 2015-02-28
2016-02-28 | 2015-02-28
2016-02-07 | 2015-02-27You could create such a table manually and upload using a file upload connector. Or you might build it within Domo using the calendar dataset in the Domo Dimensions connector and then creating your PY date field using logic similar to what you described.
Then, you would simply join your CY/PY calendar in your Magic ETL dataflow and use it to look up the PY date.
Hope that's helpful.
Dan
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.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 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