Period over Period (MOM/YOY) option in Multi-Value card for 2 months prior
I am building a dashboard that only shows completed months' worth of data. A few of the datasets I have though provide lagging data.... so for their specific cards, I just want to show data up until the prior month.
I have created multi-value cards to show the MOM and YOY trends... they work when I have a completed dataset (as shown below), but I can't figure out how to get this to work for comparing two months ago (so today for a card pulling from a dataset that has incomplete data for February, I'd want to compare January '22 to December '21 and January '21). Is there a way to do this?
Best Answers
-
On the cards where you want to show only data from prior months you could create a beast mode that you would put in your filters. It might look like this:
CASE WHEN `dt` < DATE_SUB(CURRENT_DATE(), INTERVAL (DAYOFMONTH(CURRENT_DATE()) - 1) DAY) THEN 'Prior' ELSE 'Current' END
Replace dt with your fieldname that has the date.
You would then put this beast mode in your filter and set the filter to Prior. This will hide any data in the current month.
**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.1 -
@NathanDorsch with your concatenation:
Date(concat( case when Month(`Date`) > 1 then Year(`Date`) when Month(`Date`) = 1 then Year(Date) - 1 end, '1', case when Month(`Date`) > 1 then Month(`Date`) - 1 when Month(`Date`) = 1 then 12 end ))
A date of today would return 202213. The date() function is going to have a hard time converting that to a date.
If you want to go this route, I would change it to:
Date(concat( case when Month(`Date`) > 1 then Month(`Date`) - 1 when Month(`Date`) = 1 then 12 end , '/1/', case when Month(`Date`) > 1 then Year(`Date`) when Month(`Date`) = 1 then Year(Date) - 1 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.2 -
@NathanDorsch glad I was able to help. If you can accept any answers that helped you, that will help others in the community.
**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.3
Answers
-
On the cards where you want to show only data from prior months you could create a beast mode that you would put in your filters. It might look like this:
CASE WHEN `dt` < DATE_SUB(CURRENT_DATE(), INTERVAL (DAYOFMONTH(CURRENT_DATE()) - 1) DAY) THEN 'Prior' ELSE 'Current' END
Replace dt with your fieldname that has the date.
You would then put this beast mode in your filter and set the filter to Prior. This will hide any data in the current month.
**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.1 -
hmmm... that didn't quite work. I'm thinking what I could do though is create a beast mode that simply subtracts one month from each date... or better yet (since not all months have the same number of days), can I create a beastmode with the prior month to each date? I could then use this in the Time Period.
So if the date is February 27, 2022, it will return January 2022. How can I do that?
0 -
I tried this and it doesn't seem to be working... What might I be doing wrong here>?
Date(concat(
case when Month(`Date`) > 1 then Year(`Date`)
when Month(`Date`) = 1 then Year(Date) - 1
end,
'1',
case when Month(`Date`) > 1 then Month(`Date`) - 1
when Month(`Date`) = 1 then 12
end
))
0 -
You can use the DATE_SUB function to subtract different intervals at a time, such as month.
DATE_SUB
Subtracts date or datetime values (as intervals) to date values in a date column.
DATE_SUB('DateCol', interval 1 month)
In this example, if the value for DateCol was 2/27/2022, it would subtract 1 month and result in 1/27/2022. Now, if you needed to get to the last day of the month if the month you just subtracted to, you can wrap the LAST_DAY() function around the Date_Sub function. This would make 1/27/2022 end up being 1/31/2022.
LAST_DAY(DATE_SUB('DateCol', interval 1 month))
Let me break down a part of my first example in case that might help you as well.
DATE_SUB(CURRENT_DATE(), INTERVAL (DAYOFMONTH(CURRENT_DATE()) - 1) DAY)
There are several functions wrapped together here.
CURRENT_DATE() is returning today's date whenever the card is viewed.
DAYOFMONTH(CURRENT_DATE()) - 1) is returning the day of today's date and reducing that by 1. So, if today is the 3rd, then this would return 2. This number is then used in the DATE_SUB function to subtract the number of days from today's date.
The result of the entire function returns the first day of the current month. So, right now, it would return 3/1/2022.
**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.4 -
@NathanDorsch with your concatenation:
Date(concat( case when Month(`Date`) > 1 then Year(`Date`) when Month(`Date`) = 1 then Year(Date) - 1 end, '1', case when Month(`Date`) > 1 then Month(`Date`) - 1 when Month(`Date`) = 1 then 12 end ))
A date of today would return 202213. The date() function is going to have a hard time converting that to a date.
If you want to go this route, I would change it to:
Date(concat( case when Month(`Date`) > 1 then Month(`Date`) - 1 when Month(`Date`) = 1 then 12 end , '/1/', case when Month(`Date`) > 1 then Year(`Date`) when Month(`Date`) = 1 then Year(Date) - 1 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.2 -
@MarkSnodgrass and @GrantSmith You guys are killing it! Thank you.
I'll take your correction of my formula, as that appears to work. I was strugglign to follow on the other suggestion... but probably my own mental limitation 😏
0 -
@NathanDorsch glad I was able to help. If you can accept any answers that helped you, that will help others in the community.
**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.3 -
How do I accept? My clicking on Yes to the "Did this answer the question?"
1 -
@NathanDorsch Yep! That did it! Thanks!
**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.2
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
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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