Creating a Beast Mode to calculate field sums for remainder of year
Hi - I am trying to write a beast mode calculation that sums a field from an as of date until the end of the year. The variable is indexed across the year and want to count how many are left depending on what date is entered. For instance if 1/22/24 was the date it would count all the values indexed for the variable until 12/31/24 and so on.
Here is what I have but doesnt seem to fully work.
SUM(CASE WHEN index
>= date
AND index
<= LAST_DAY(CURRENT_DATE() + INTERVAL (12 - MONTH(CURRENT_DATE())) MONTH) THEN (variable
) END)
Best Answer
-
an easy way to get the last day of the year is to do this:
DATE(CONCAT('12/31/',YEAR(CURRENT_DATE())))
You can put this in place of your 2nd date piece.
**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
Answers
-
an easy way to get the last day of the year is to do this:
DATE(CONCAT('12/31/',YEAR(CURRENT_DATE())))
You can put this in place of your 2nd date piece.
**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 -
What issue are you experiencing? How is it not working? Have you tried splitting out your conditions into separate beast modes and using a table card to see the values for each row of data?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
@MarkSnodgrass thanks for the suggestion. Unfortunately when i make that update i get an error saying "An issue has occurred during processing. We are unable to complete the request at this time."
@GrantSmith the current equation isn't aggregating and calculating the totals correctly with the snippet I first mentioned. Can you elaborate further on the last question?
0 -
Try this, though you'll need to re-type the index and variable fieldnames if they don't paste in correctly.
SUM(CASE WHEN index >= date AND index <= DATE(CONCAT('12/31/',YEAR(CURRENT_DATE()))) THEN variable 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 -
I retyped the field names when I copied this over but I needed to change current_date to the date field I have since some of the data is in past years so it pulls correctly. but still got the same error where the chart wont load
0 -
I realized I didn't replace the other current_date references with date. it worked this time
thanks for the assistance!
1
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