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
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 664 Datasets
- 120 SQL DataFlows
- 2.3K Magic ETL
- 825 Beast Mode
- Visualize
- 2.6K Charting
- 88 App Studio
- 46 Variables
- Automate
- 196 Apps
- 486 APIs & Domo Developer
- 94 Workflows
- 24 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 119 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 143 Governance & Security
- 11 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive