Leap Year Fix
I noticed that our DOMO was pulling different trend %'s as compared to our regular route accounting software and in digging, I found it to be due to this year being a leap year.
When we first launched DOMO, the developer put in a beastmode to use as a slicer so that it would look at sales through the last full business day and compare it to the same date the prior year and we just named it "Future/Historic" and it defaulted to "Historic" so it matched our regular accounting software:
CASE WHEN (DAYOFYEAR(`date`) < DAYOFYEAR(CURRENT_DATE())) THEN 'Historic' ELSE 'Future' END
This worked fine until leap year date (February 29th) occured, then it began showing sales trends inaccurately when selected (Example: comparing 3/1/2020 - 3/25/2020 to 3/1/2019 - 3/26/2019). In order to have it compare {3/1/2020 - 3/25/2020} to {3/1/2019 - 3/25/2019}, I made a simple case statement adjustment - shown below:
CASE WHEN YEAR(`date`) = 2020 THEN
(CASE WHEN (DAYOFYEAR(`date`) < DAYOFYEAR(CURRENT_DATE())) THEN 'Historic' ELSE 'Future' END )
WHEN YEAR(`date`) = 2019 THEN
(CASE WHEN (DAYOFYEAR(`date`) + 1 < DAYOFYEAR(CURRENT_DATE())) THEN 'Historic' ELSE 'Future' END )
ELSE 0 END
I hope this helps someone else that may have a similar issue to deal with. I'm sure there are other ways to fix this issue, but this was a quick fix that worked...
Comments
-
If you are just looking to denote if it is historical...
Why not just use
CASE WHEN `date` < CURRENT_DATE() then 'Historic' ELSE 'Future' End
**** I just read the question a in a little more detail.
Your solution is only going to work if you are already past leapday. and only for 2020. I would try to use something more dynamic. Let me see if I have time to post a solution later today
0 -
I think this will get to what you are looking for:
case
when month(`Date of Invoice`)<MONTH(CURDATE()) then 'Historic'
when month(`Date of Invoice`)>MONTH(CURDATE()) then 'Future'
when day(`Date of Invoice`)<DAY(CURDATE()) then 'Historic'
else 'Future'
endIn this statement, if the month is less than the current month then it is historic. If the month is greater, then it is future.
If it is equal to the current month, then it looks at the day in the month to determine. If the day is less than the current day, then historic. Otherwise, future.
0 -
careful of just considering the MONTH of the date. You'll combine years in cross year analysis.
add YEAR() comparison to the beast mode.
to combine year and month i do year()*100+month()
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 302 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 633 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 760 Beast Mode
- 62 App Studio
- 42 Variables
- 699 Automate
- 181 Apps
- 457 APIs & Domo Developer
- 51 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive