BeastMode Help: Days Remaining in Quarter
I've got a beastmode I am trying to create that will calculate the days remaining in a quarter.
- If the quarter is already over I want to show a value of 0 (not a negative number).
- If the quarter hasn't started I want to show 91 (that's the number of days in a quarter)
Any help would be appreciated. Also if this is better handled in ETL I can go that way as well.
This is the concept I am working with (not currently working, and does not include the):
Case
when
DATEDIFF(CURDATE(),
case
when `Count Quarter`='Q1' then DATE(3/31/2020)
when `Count Quarter`='Q2' then DATE(6/30/2020)
when `Count Quarter`='Q3' then DATE(9/30/2020)
when `Count Quarter`='Q4' then DATE(12/31/2020)
else 0
end
)>91 then 91
when
DATEDIFF(CURDATE(),
case
when `Count Quarter`='Q1' then DATE(3/31/2020)
when `Count Quarter`='Q2' then DATE(6/30/2020)
when `Count Quarter`='Q3' then DATE(9/30/2020)
when `Count Quarter`='Q4' then DATE(12/31/2020)
else 0
end
)<0 then 0
else
DATEDIFF(CURDATE(),
case
when `Count Quarter`='Q1' then DATE(3/31/2020)
when `Count Quarter`='Q2' then DATE(6/30/2020)
when `Count Quarter`='Q3' then DATE(9/30/2020)
when `Count Quarter`='Q4' then DATE(12/31/2020)
else 0
end
)
end
Best Answer
-
If I were you, I would create a Date Dimension that has one row per day, and includes, 'End Of Quarter' as a date. Then JOIN that dataset to your transactions using a FUSION.
Then in Beast mode you can calculate datediff(ActivityDate, EndofQuarter) You could wrap all that in a CASE statement to calculate if Activity Date is less than Start of Current Quarter (
SELECT MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE()) QUARTER
- INTERVAL 1 QUARTER)
https://stackoverflow.com/questions/11884618/how-do-i-get-the-first-date-of-a-quarter-in-mysql
Hope that helps!
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Answers
-
If I were you, I would create a Date Dimension that has one row per day, and includes, 'End Of Quarter' as a date. Then JOIN that dataset to your transactions using a FUSION.
Then in Beast mode you can calculate datediff(ActivityDate, EndofQuarter) You could wrap all that in a CASE statement to calculate if Activity Date is less than Start of Current Quarter (
SELECT MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE()) QUARTER
- INTERVAL 1 QUARTER)
https://stackoverflow.com/questions/11884618/how-do-i-get-the-first-date-of-a-quarter-in-mysql
Hope that helps!
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Thanks @jaeW_at_Onyx - YOU ROCK!
0
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