Beast Mode Help
Help, my brain is stuck. I am trying to come up with a BM that will filter my data. I have an orders dataset and for some reason someone chose Wednesday as their reporting day. I want to show that if the day is Wednesday then we will show orders from the current Wednesday to the past Wednesday. But if we have not reached Wednesday yet then we should the previous Wednesday to the Wednesday before. Filed is just an order date. I am trying to use some combination of day of week functions and cur date but having some trouble.
So as of today I would show orders from 3/9-3/16 but tomorrow it will switch to 3/16-3/23.
**If this answer solved your problem be sure to like it and accept it as a solution!
Best Answer
-
@Ashleigh I believe this will work for you:
/* check to see if today is Wednesday */ CASE WHEN DAYOFWEEK(CURRENT_DATE()) = 4 THEN /*its Wednesday, so just show the last 7 days */ CASE WHEN `date` >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK) AND `date` <= CURRENT_DATE() THEN 'Include' ELSE 'Exclude' END WHEN DAYOFWEEK(CURRENT_DATE()) > 4 THEN /* its Thursday or later, so just show the most recent week */ CASE WHEN `date` >= DATE_ADD(DATE_SUB(CURRENT_DATE(), INTERVAL 2 WEEK), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) AND `date` <= DATE_SUB(CURRENT_DATE(), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) THEN 'Include' ELSE 'Exclude' END ELSE /* its not Wednesday yet, go back an extra week */ CASE WHEN `date` >= DATE_ADD(DATE_SUB(CURRENT_DATE(), INTERVAL 2 WEEK), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) AND `date` <= DATE_ADD(DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) THEN 'Include' ELSE 'Exclude' END END
couldn't easily test since I was using current_date, but I think should work for you.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.2
Answers
-
You can use a CASE Statement and DAYOFWEEK to check if it's before Wednesday and then configure and setup your date filters
CASE WHEN DAYOFWEEK(CURRENT_DATE()) <=4 THEN offset logic here END
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
@Ashleigh I believe this will work for you:
/* check to see if today is Wednesday */ CASE WHEN DAYOFWEEK(CURRENT_DATE()) = 4 THEN /*its Wednesday, so just show the last 7 days */ CASE WHEN `date` >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK) AND `date` <= CURRENT_DATE() THEN 'Include' ELSE 'Exclude' END WHEN DAYOFWEEK(CURRENT_DATE()) > 4 THEN /* its Thursday or later, so just show the most recent week */ CASE WHEN `date` >= DATE_ADD(DATE_SUB(CURRENT_DATE(), INTERVAL 2 WEEK), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) AND `date` <= DATE_SUB(CURRENT_DATE(), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) THEN 'Include' ELSE 'Exclude' END ELSE /* its not Wednesday yet, go back an extra week */ CASE WHEN `date` >= DATE_ADD(DATE_SUB(CURRENT_DATE(), INTERVAL 2 WEEK), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) AND `date` <= DATE_ADD(DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK), INTERVAL (4 - DAYOFWEEK(CURRENT_DATE())) DAY) THEN 'Include' ELSE 'Exclude' END END
couldn't easily test since I was using current_date, but I think should work for you.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.2 -
@MarkSnodgrass Thanks, this worked!!! My brain was hurting trying to figure this one out lol
**If this answer solved your problem be sure to like it and accept it as a solution!
1
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