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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive