How to create a card with data from the calendar month before last
Hi, does anyone have any thoughts on how to create a card that contains rolling data for a calendar month that was 2 months ago?
Example 1, If today's date is June 15th, card should show data for the whole month of April
Example 2, If today's date is November 30th, card should show data for the whole month of September
You've got two options.
1) You could use a beast mode to determine if a date is from 2 months ago
CASE WHEN LAST_DAY(CURDATE() - INTERVAL '2' MONTH) = LAST_DAY(`Date Field`) THEN 1 ELSE 0 END
and then just filter on that value being 1.
This method you're always stuck looking at 2 months ago according to the current month. The next option is better in that it will allow you to look at 2 months ago based on any date you have selected in your chart.
2) The more robust option would be to create a custom date dimension table where you have customized offsets (With a report date and a comparison date). You'd then use a Fusion / View to join that dataset to your main dataset based on your date field and the comparison date field. You then can filter for your offset type of 2 months ago. This has been outlined several times here on the dojo. See https://dojo.domo.com/t5/Card-Building/show-percent-on-period-over-period-graph/m-p/50540/highlight/true#M7313.
I highly recommend method 2 as it gives you much more flexibility when processing and displaying your data.
Also @jaeW_at_Onyx has a nice video he put out which outlines this process as well:**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2
Hi @GrantSmith - method 1 works perfectly and has now been rolled out to a suite of cards. For this purpose, being 'stuck' working from the current date is ok, the cards are being used to schedule a monthly export of raw data to a third party.
Method 2 is excellent for not relying on reference to the current date and I will no doubt use it in the future for another card.
Thanks for your help!0
@richardjmarshall One piece of advise that I would offer. And this is just to provide some more clarity and flexibility to the field that you are filtering on. I would recommend not just using 'THEN 1 ELSE 0'
CASE WHEN LAST_DAY(CURDATE() - INTERVAL '2' MONTH) = LAST_DAY(`Date Field`) THEN '2 Months Ago' ELSE 'Other' END
Using something like this makes it more intuitive for anyone else using this filter to understand what they are filtering for. In addition, you could add more options:
CASE WHEN LAST_DAY(CURDATE() - INTERVAL '2' MONTH) = LAST_DAY(`Date Field`) THEN '2 Months Ago' WHEN LAST_DAY(CURDATE() - INTERVAL '1' MONTH) = LAST_DAY(`Date Field`) THEN '1 Month Ago' ... etc. ELSE 'Other' END
Users could then use this field to dynamically set a default view for any number of months they wanted the card to look back to.
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman
- 7.7K All Categories
- 917 Connectors
- 242 Workbench
- 474 Transform
- 1.8K Magic ETL
- 60 SQL DataFlows
- 446 Datasets
- 34 Visualize
- 198 Beast Mode
- 2K Charting
- 8 Variables
- 15 Cards, Dashboards, Stories
- 1 Automate
- 348 APIs & Domo Developer
- 82 Apps
- 14 Predict
- 3 Jupyter Workspaces
- 11 R & Python Tiles
- 241 Distribute
- 59 Domo Everywhere
- 241 Scheduled Reports
- 15 Manage
- 36 Governance & Security
- 23 Product Ideas
- 1.1K Ideas Exchange
- Community Forums
- 15 Getting Started
- 1 Community Member Introductions
- 49 Community News
- 18 Event Recordings
- 579 日本支部