beast mode for latest 12 months
Hi
I need help creating a beast mode to show monthly gross rev for the latest 12 months. I have example on how I get my YTD gross rev below. I not sure if it can be dome in beast mode or any other way. Your help will be appreciated. Thank you in advance.
SUM(CASE WHEN `Year`= `Year for Today` AND `Month #` <=`Month # for Today`
THEN `Gross Revenue`
ELSE 0
END)
Comments
-
Hi @user033690
You can utilize some built in functions to get the current date and do some addition / subtractions.
CURRENT_DATE() will get you the current date
MONTH() and YEAR() returns the month and year of the date respectively.
We can do some math trickery to make the YEAR and MONTH a digit and compare the two values together.
CASE WHEN `Year` * 100 + `Month #` <= YEAR(CURDATE() - INTERVAL '12' MONTH) * 100 + MONTH(CURDATE() - INTERVAL '12' MONTH) THEN `Gross Revenue` ELSE 0 END
You'll get a number like 201910 and compare it to 202010 which is greater or equal and return the Gross Revenue.
This is assuming you're wanting to include the current month from last year (which would be a little over 12 months)
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
If you're using a specific date field instead of the current date you could format it with the same structure like:
CASE WHEN `Year` * 100 + `Month #` <= `Year For Today` * 100 + `Month # For Today` THEN `Gross Revenue` ELSE 0 END
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
@GrantSmith 's answers are spot on as usual. I think it is worth pointing out that you can use the date filter to only pull the last 12 months and that would save you the work of the beast mode, depending on what you are trying to do. Thought I would mention it as some people forget that it is there and all the options it provides without having to do anything.
**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
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