Comparing YOY trend lines
I'm struggling with building a chart to show YOY trends. I was able to use a combination of the following beastmodes to create the following chart from a dataset containing a small amount of data. But when I attempt to do this with a large dataset, it doesn't work (I'm wondering if it just requires too much processing).
Can anyone advise on how to do this better? I'm thinking the extensive case statements is bogging this down.
Is there an easy way to just convert all dates into the last 12 months (so if its 5/7/21, it would be converted to 5/7/23)?
X Axis BM value: Common date (Last 6 mos):
CASE
WHEN EVENT_DATE
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 5 MONTH) THEN SUBDATE(EVENT_DATE
, INTERVAL DAYOFMONTH(EVENT_DATE
) DAY)+1
WHEN EVENT_DATE
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 17 MONTH)
AND EVENT_DATE
< SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 11 MONTH) THEN ADDDATE(SUBDATE(EVENT_DATE
, INTERVAL DAYOFMONTH(EVENT_DATE
) DAY)+1, INTERVAL 1 YEAR)
WHEN EVENT_DATE
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 29 MONTH)
AND EVENT_DATE
< SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 23 MONTH) THEN ADDDATE(SUBDATE(EVENT_DATE
, INTERVAL DAYOFMONTH(EVENT_DATE
) DAY)+1, INTERVAL 2 YEAR)
WHEN EVENT_DATE
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 41 MONTH)
AND EVENT_DATE
< SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 35 MONTH) THEN ADDDATE(SUBDATE(EVENT_DATE
, INTERVAL DAYOFMONTH(EVENT_DATE
) DAY)+1, INTERVAL 3 YEAR)
ELSE ''
END
Series BM value: Series (for Asia)
CASE
WHEN event_date
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 5 MONTH) THEN 'Last 6 months'
WHEN event_date
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 17 MONTH)
AND event_date
< SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 11 MONTH) THEN '1 year ago'
WHEN event_date
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 29 MONTH)
AND event_date
< SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 23 MONTH) THEN '2 years ago'
WHEN event_date
>= SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 41 MONTH)
AND event_date
< SUBDATE(SUBDATE(CURDATE(),DATEDIFF(CURDATE(),SUBDATE(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) DAY)+1)), INTERVAL 35 MONTH) THEN '3 years ago'
ELSE ''
END
Answers
-
@NathanDorsch this video may help you where I show how to move dates from different years into the current year so that you can do a year over year comparison.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
Thanks @MarkSnodgrass I should have clarified… The main issue I'm running into is trying to eliminate the currently (incomplete) month. Is there a way to pull the last 12 complete months?
So right now, I'd want to see the first column on the left be September ending in August. Below is what I see with the basic bar line POP chart. And how to I replace the "last 12 months" with "current" and "12 months ago" with "Prior Year"?
0 -
Typically when I'm doing PoP analysis I'll use a custom date dimension to add more flexibility for what I want to do. I'd recommend reading this article that I've written up in the past on how to get this configured and used.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
I do have a video about incomplete months as well if you want to watch it, but the short answer is to change your date range filter to 13 months and then create a beast mode that checks to see if the data is in the current month and exclude it, otherwise include it. Drag that into your filters and filter to include. Here is an example:
CASE WHEN LAST_DAY(transactiondate
) = LAST_DAY(CURRENT_DATE()) THEN 'Exclude'
ELSE 'Include'
END**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
@MarkSnodgrass I did somethign similar where I created a "difference month" BM - PERIOD_DIFF(date_format(
EVENT_DATE
,'%Y%m'),date_format(now(),'%Y%m'))I filtered to include data < 0.
The problem is then I see this… where it'll show September (from last year) twice - both on the left and right.
0 -
You might try just comparing the months and not the month and year because the line is showing last year which would be less than zero in this case. Also, I find the period over period charts to be particularly difficult to work with. That could also be the issue.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
@GrantSmith @MarkSnodgrass This is what I'm trying to do. The chart will show the last 12 complete months and the value for the prior year's month to that? I don't want to see the current month on the right side. For right now, I'd want to see September 2022 listed on the far left side of the chart (with September 2022 as the bar vale and September 2021 as the line value).
Is there a way to do this?
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive