How to show week-by-week comparisons in grouped vertical bar cards where the weeks roll-over years?

When I got into work this morning, the Grouped Vertical Bar cards which I had built to show week-by-week comparisons of THIS year's values versus LAST year's values were all broken.
The Beast Modes that I had created to differentiate by week were all malfunctioning because today is Wednesday, January 2, 2019, and the end of "Last" week was Monday, December 31, 2018.
The issue was that I needed to represent each week independently, and also sequentially, so that week 52 of 2018 will preceed week 1 of 2019.
The easiest "fix" that I could construct was to think of the week number for each year as a strictly numerical value -- rather than a string to be sorted -- so that they could be displayed left-to-right across the x-axis.
Here's a sample of the part of the Beast Modes that I created to accomplish this:
/* To compare the `date` of any row of data to that of the CURRENT_DATE() */
(abs(year(`date`))*52 + abs(weekofyear(`date`))) = (abs(year(CURRENT_DATE()))*52 + abs(weekofyear(current_date())) -2)
/* Accepting data where the date is from TWO Weeks ago! */
As you can see, each week number is calculated as the sum of the absolute value of the result of the "weekofyear" function plus 52 times the absolute value of the result of the "year" function - so that Dec 2018 is equal to 104948 internally, and Jan 2019 is likewise equal to 104949.
While any constant can be used in order to sort months BY ORDER, using 52 as the constant allows them be ordered SEQUENTIALLY.
I hope that this helps someone else as much as it helped me!
Respectfully,
Dean T. Pangelinan
Marketing Data Analyst – Technical Solutions, Global Marketing Analytics
Robert Half
Comments
-
Any Beast Mode gurus out there who want to chime in on this one?
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