Grouping by the Hour and alerting based on count of usage per hour.
Hello,
I am trying to do a group by using hour of day. The date operator in Magic does not have that funcationality but curious how I can do it within magic or in SQL. Here is my data where I want to count how many times a code was use in an hour for each day I want to use.
COUPON-CODE | updated_at | Order # | Goal(Count of Usage by Hour) |
10% | 17-Apr-20 10:04:53 | 1 | 2 |
10% | 17-Apr-20 10:43:49 | 2 | 2 |
10% | 17-Apr-20 5:43:25 | 3 | 1 |
10% | 17-Apr-20 0:46:53 | 4 | 1 |
10% | 17-Apr-20 17:10:14 | 5 | 1 |
20% | 17-Apr-20 2:51:38 | 6 | 1 |
20% | 17-Apr-20 6:42:59 | 7 | 1 |
20% | 17-Apr-20 13:24:49 | 8 | 2 |
20% | 17-Apr-20 13:53:14 | 9 | 2 |
50% | 17-Apr-20 15:51:46 | 10 | 1 |
50% | 17-Apr-20 16:02:26 | 11 | 3 |
50% | 17-Apr-20 16:27:03 | 12 | 3 |
50% | 17-Apr-20 16:27:03 | 13 | 3 |
Best Answer
-
In Magic: create a copy of the column converted to TEXT and do a REGEX / STRING transform.
In MySQL: use date_part functions (like hour).
Best Solution: split date and time (HH:mm) into separate columns during data ingestion. THEN use a Fusion to join a Time Dimension table (where you have one row for every minute of the day).
Why is Fusion the best model?
Because it minimizes the number of times you have to read and write the data. AND by using a Time dimension you can create custom groupings like ("Morning", "coffee-break", "evening") without using a complex beast mode in each of your cards.
Why does splitting date_time make sense?
Because you'll want to see a trend in behavior on Saturdays versus trend in behavior on Mondays. By using a Time dimension you can avoid ugly beast modes.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"2
Answers
-
Do you have the time stamp for the hours you're wanting to graph? Domo now supports hour granularity in the time slicer so you could graph by hour. You could also possibly use the HOUR function in a beast mode might work as well
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Hello,
It just won't work for the alert. You have to group it to give it a trigger.
0 -
What are you attempting to alert on?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
In Magic: create a copy of the column converted to TEXT and do a REGEX / STRING transform.
In MySQL: use date_part functions (like hour).
Best Solution: split date and time (HH:mm) into separate columns during data ingestion. THEN use a Fusion to join a Time Dimension table (where you have one row for every minute of the day).
Why is Fusion the best model?
Because it minimizes the number of times you have to read and write the data. AND by using a Time dimension you can create custom groupings like ("Morning", "coffee-break", "evening") without using a complex beast mode in each of your cards.
Why does splitting date_time make sense?
Because you'll want to see a trend in behavior on Saturdays versus trend in behavior on Mondays. By using a Time dimension you can avoid ugly beast modes.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"2 -
Hi,
Trying to alert anytime I have a code used more than 3 times an hour.
0 -
I know this doesn't help you now, but given that you and several other users voiced challenges dealing with date and time data, i'm going to run a mini-hackathon on handling date and time in Domo next week thursday.
You're welcome to join: https://dojo.domo.com/t5/EMEA/DUG-Meeting-30-40-2020-1430-UTC-BUILD-IT-Working-with-DateTime/m-p/48274#M11
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 292 Workbench
- 4 Cloud Amplifier
- 8 Federated
- 2.8K Transform
- 95 SQL DataFlows
- 600 Datasets
- 2.1K Magic ETL
- 3.7K Visualize
- 2.4K Charting
- 685 Beast Mode
- 43 App Studio
- 38 Variables
- 654 Automate
- 169 Apps
- 438 APIs & Domo Developer
- 42 Workflows
- 5 DomoAI
- 32 Predict
- 12 Jupyter Workspaces
- 20 R & Python Tiles
- 383 Distribute
- 110 Domo Everywhere
- 267 Scheduled Reports
- 6 Software Integrations
- 111 Manage
- 108 Governance & Security
- 8 Domo University
- 25 Product Releases
- Community Forums
- 39 Getting Started
- 29 Community Member Introductions
- 98 Community Announcements
- Domo Community Gallery
- 4.8K Archive