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
- 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
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 36 Predict
- 15 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