Dynamic Date within Beast Mode

I have a Beast Mode that is grouping transactions based on their date:
CASE WHEN OrderHeaderLocalDate >= '02/27/2024' THEN 'Since Changes CY'
WHEN OrderHeaderLocalDate >= '08/01/2023' AND OrderHeaderLocalDate <= '02/26/2024' THEN 'Prior YTD CY'
WHEN OrderHeaderLocalDate >= '02/27/2023' AND OrderHeaderLocalDate <= '04/08/2023' THEN 'Since Changes PY'
WHEN OrderHeaderLocalDate >= '08/01/2022' AND OrderHeaderLocalDate <= '02/26/2023' THEN 'Prior YTD PY'
ELSE 'Not in Scope'
END
This works fine, and I was using another piece of data to figure out a Year to Date period for current and prior year so it was original 07/31/2023 in place of the 04/08/2023, however I have since found the the YTD flag that exists within the data already works in a different way to what I expected, so is including a few more days than I want.
I've tried various iterations of changing the 04/08/2023 (08/04/2023 in UK) to be dynamic and within the beast mode I was getting a validated code, but when using in a visualization no results.
I have tried finding the Max date within OrderHeaderLocalDate - 366 days (leap year), this worked within a beast mode and then visualisation, but within the case seems to be a no go.
Is anyone able to help with a solution to change 04/08/2023 to what is effectively the most recent order within the dataset minus 1 year within the case statement? This means that each day when the dataset is updated with the latest transactions I won't have to make an amend every day!
I'm sure there is a simple solution I am making massively more complicated than it needs to be!
Thanks!
Answers
-
You can try and utilize a window function for your date instead of '04/08/2023':
MAX(`OrderHeaderLocalDate`) OVER () - INTERVAL 1 YEAR
This will look across your entire dataset and get the maximum date and return it for each row.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Thanks for this Grant, strangely this was allowed, however it didn't bring any data back even though you could see it within the filter, so I'll try a few more things to try and narrow down my issue!
0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 656 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive