Hour-over-Hour for the past 24 hours
Hi,
I have been trying to figure out how to graph performance of applications for each hour in a rolling 24-hour period (and once I get that then I need to do it hourly for a rolling 30 days). My database behind the scenes is a MySQL database where I added a calculated column so that I would have just the date and the hour of the timestamp (we use military time). This is what produces that output:
SELECT IF(HOUR(timestamp) < '10', (CONCAT_WS(":", DATE(timestamp), CONCAT('0', HOUR(timestamp)))),
(CONCAT_WS(":", DATE(timestamp), HOUR(timestamp))))
FROM tablename;
I can graph this and it makes for nice aggregation on this field, but I need to be able to limit it to just the past 24 hours, and there is no simple drop-down option for this like there is for the current day, so I'm trying to calculate this using Beastmode. Right now, I am trying to set 1's and 0's for quick easy filtering using this:
CASE WHEN ADDATE(CURRENT_TIMESTAMP(),-1) < `DeviceLocalTime` THEN 1 ELSE 0
But I keep getting a syntax error, and I'm not sure why as Beastmode doesn't really tell you where you have an error and clearly, it's not exactly the SQL I know. Has anyone else figured this out? Please, help.
Best Answer
-
Looks like you might be missing a D from ADDDATE and the END of the CASE.
Try this: CASE WHEN ADDDATE(CURRENT_TIMESTAMP(),-1) < `DeviceLocalTime` THEN 1 ELSE 0 END
If that's not it, let me know and I'll take another look.
Sincerely,
ValiantSpur
**Please mark "Accept as Solution" if this post solves your problem
**Say "Thanks" by clicking the "heart" in the post that helped you.2
Answers
-
Looks like you might be missing a D from ADDDATE and the END of the CASE.
Try this: CASE WHEN ADDDATE(CURRENT_TIMESTAMP(),-1) < `DeviceLocalTime` THEN 1 ELSE 0 END
If that's not it, let me know and I'll take another look.
Sincerely,
ValiantSpur
**Please mark "Accept as Solution" if this post solves your problem
**Say "Thanks" by clicking the "heart" in the post that helped you.2 -
Oh my gosh! One little 'D' is what was messing me up. Thanks a million. It works now.
2 -
No worries! I've done it many times myself. Always good to have a second pair of eyes ?
1 -
Valiant- Have you figured out a way to filter data for a YoY chart based on the Max hour for the current day? For example, if I only have data through 9 am today then I want a period over period (today vs. same fiscal day last year) card with data only through the 9 am hour for last year as well. Make sense?
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
- 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