Alert Bases on Average for Day of Week

For a daily alert, we can not merely measure the difference between two consecutive days because day of week matters - we have much lower traffic on the weekends, a Monday peak followed by a typical slow decline. 

 

What I would like to do for an alert is something like this:

For the particular day of week, if variance of the count of records is more than +/- 20%, as compared to the AVERAGE COUNT count of records for the same day of week over the last 60 days, then alarm.

 

I have messed with beast modes, and don't want to do a data flow if i don't have to. Any suggestions? Thanks. 

Comments

  • Because you're wanting to do an average of the count (an aggregate of an aggregate) BeastMode won't be able to help you. You'll need to utilize a data flow to track your running total / count and then you could utilize a beast mode to calculate the difference between your current day's value and the average count.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • So, a whole new table that tracks a rolling average? Probably one column per day so that i could keep the rolling averages and get trending? Or should i just have one column with 7 rows that get update daily? Thanks.

  • If you don't care about keeping a historical record you could do it with the MagicETL

    - Date Operation to get the Day of Week on your main data set

    - Split your main dataset using a filter to pull the last 60 days

        - Group On Day of Week - calculating the average

        - Join this grouping back to your original dataset (that you fed into the group by) based on the day of the week

    - Can either calculate the difference between the day in the ETL or in a BeastMode and utilize that as your summary number to alert on.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Still having trouble with this, might just be my understanding.

     

    Mainly, i want average by day of week for each vendor.

     

    Then, in my main data, i want to alert comparing the current day to the average for that day for that vendor, and alert off of a percent difference. 

     

    I have a stacked bar for each day, with vendor as the series. All I need to do is, for each vendor, compare their numbers to their average for that day of week. 

     

    vendorperday.PNG

    If I follow your method above, should my new data table only contain counts or averages per vendor per day? And if i join that back to the main data (individual transactions), on what do i join it? Do I add the average value to each row for each vendor to each individual transaction? If so, how will that be referenced against the graph's summary numbers for each vendor, since that summary appears on every row?

     

    Thanks from a newb

  • @GrantSmith  could you do something like

     

    sum(1) as daily_record_count,

    avg(sum(1)) over () as 60_day_rolling_avg ,

    (

    sum(1) 

    avg(sum(1)) over ()

    ) / 

    avg(sum(1)) over () as percent_Change

    FROM ...

    WHERE

    DATEDDIFF(date, current_date()) between 1 and 60

    GROUP BY date

     

    EDIT:: pardon my pseudocode, i'll try to test later.

     

    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"
  • Thanks so much for your prompt answer. But then how does the join work back to the individual transaction data?

  • So for my first query, I've created this (as a transform).  Not sure how to now add a count for just one day (yesterday). Also, not sure if a transform works because then how do i pull data from both this transform and the original data table for the one day count?

    select
    count(*) AS SIXTYDAYCOUNT
    , CURRENT_DATE-1 as Date
    , `PARTNER_NAME`
    , `PARTNER_EVENT_TYPE`
    From `prd_resume_feed_resumefeed_resume_feed_xactn`
    WHERE
    `INSRT_DTTM` between CURRENT_DATE-61 and CURRENT_DATE-1
    GROUP BY
    `PARTNER_NAME`
    , `PARTNER_EVENT_TYPE`

  • So the more I think about this, what i need i one output is

    A rolling 60d average 

    A count for yesterday

    grouped by:

       yesterday's date

       partner name

       transaction_type

     

    Got to be easy, but...