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-CODEupdated_atOrder #Goal(Count of Usage by Hour)
10%17-Apr-20 10:04:5312
10%17-Apr-20 10:43:4922
10%17-Apr-20 5:43:2531
10%17-Apr-20 0:46:5341
10%17-Apr-20 17:10:1451
20%17-Apr-20 2:51:3861
20%17-Apr-20 6:42:5971
20%17-Apr-20 13:24:4982
20%17-Apr-20 13:53:1492
50%17-Apr-20 15:51:46101
50%17-Apr-20 16:02:26113
50%17-Apr-20 16:27:03123
50%17-Apr-20 16:27:03133

Best Answer

  • jaeW_at_Onyx
    jaeW_at_Onyx Coach
    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"

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!**
  • Hello,

     

    It just won't work for the alert.  You have to group it to give it a trigger.

  • 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!**
  • jaeW_at_Onyx
    jaeW_at_Onyx Coach
    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"
  • Hi,

     

    Trying to alert anytime I have a code used more than 3 times an hour.

  • This is right but the issue now is that is goes from this to this:

    2020-04-21T00:00:41
     
     
    Apr 20, 2020 5:00:41 PM
     
    Figuring that out right now but thanks for the solution!
  • @DMJerryVuori , 

    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"