Date Range Buckets
Hello,
I am trying to create a way to look at upcoming estimated shipping dates but I keep getting an "error during processing" .
I have made buckets for WIP based off days in shop field and basic case formulas in the past with no issues (See attached).
I think I am having issues with my approach due to this being dates instead of a raw value.
In theory:
case when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 3 days) then ‘next 3 days’ else
case when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 7 days) then ‘next 7 days’ else
case when `est_ship_date’ < DATE_ADD(CURRENT_DATE()interval 14 days) then ‘next 14 days’ else
case when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 21 days) then ‘next 21 days’ else
'Over 21 days' end end end end
Best Answer
-
your syntax for a case statement is wrong.
case
when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 3 days) then ‘next 3 days’
when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 7 days) then ‘next 7 days’
when `est_ship_date’ < DATE_ADD(CURRENT_DATE()interval 14 days) then ‘next 14 days’
when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 21 days) then ‘next 21 days’
else 'Over 21 days'
end
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"2
Answers
-
your syntax for a case statement is wrong.
case
when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 3 days) then ‘next 3 days’
when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 7 days) then ‘next 7 days’
when `est_ship_date’ < DATE_ADD(CURRENT_DATE()interval 14 days) then ‘next 14 days’
when `est_ship_date` < DATE_ADD(CURRENT_DATE()interval 21 days) then ‘next 21 days’
else 'Over 21 days'
end
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"2 -
I think you are missing a comma in the DATE_ADD statement. Try changing
DATE_ADD(CURRENT_DATE()interval 3 days)
to:
DATE_ADD(CURRENT_DATE(), interval 3 days)
Also I'm not sure why you have so many case/end statements? I use the following block of code for date buckets, and it works fine else-chaining without the Else/Case between, thought you might want to see to possibly shorten your code.
Case when DATEDIFF(`Event Date`,`Boxed Date`) < 0 then 'Prior to Box Date' when DATEDIFF(`Event Date`,`Boxed Date`) < 91 then 'Under 3 Months' when DATEDIFF(`Event Date`,`Boxed Date`) < 181 then '3-6 Months' when DATEDIFF(`Event Date`,`Boxed Date`) < 271 then '6-9 Months' when DATEDIFF(`Event Date`,`Boxed Date`) < 366 then '9-12 Months' when DATEDIFF(`Event Date`,`Boxed Date`) > 365 then 'Over 12 Months' when `Event Date`is null then 'Production' else 'Unknown Timeframe Error' end
4
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.8K Visualize
- 2.5K Charting
- 737 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 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