Finding the Max Average

Can someone help me build a beastmode to locate the max average?

I am trying to return the average day with that, on average, shares the highest value of the week.

By taking the max average of days, with the max average of days with the highest values, is it possible to discover the day that returns the highest avg?

I understand this may be a combination of the Magic ETL+Analyzer, but I'm stumped where to start.

Should I create another dataset that just includes the date and the values?

Answers

  • MarkSnodgrass
    MarkSnodgrass Portland, Oregon 🔵

    In Magic ETL, you could do a group by tile that calculates your first average, you could then use a rank and window tile and rank by your new average field descending. The row with a rank of 1 would be your highest average.

  • GrantSmith
    GrantSmith Indiana 🔵

    Hi @user052846

    You might be able to do this within a window function in a beast mode (filtering based on a case statement and the new aggregate filter beta - talk to your CSM to get it enabled).


    You can get the maximum average per day with the following beast mode (make sure you have date in your card or this won't work)

    MAX(AVG(`Value`)) OVER ()
    


    If you want to extrapolate that into a beast mode to filter (again, need the aggregate filter beta to do this) you can do the following:

    CASE WHEN MAX(AVG(`Value`)) OVER () = AVG(`Value`) THEN 'Max' ELSE 'Not' END
    
  • jaeW_at_Onyx
    jaeW_at_Onyx Budapest / Portland, OR 🔵

    what's your business requirement. i think most people would say you can't take the average of an average.

    you can take the max of an average.


    If i had to guess you have a bunch of transactions. you want the daily average. so you put date on the X Axis and then Avg(amount)


    That works fine. now you want the max of the daily avg.

    so then you do MAX(AVG(Amount)) OVER() as @GrantSmith describes. That'll give you the absolute max daily average across all your data. But you can't take Date off the axis because if you do, your avg, goes from daily average to absolute average and then you just get one number.


    SOLUTION

    if your requirement is to calculate max daily average across a bunch of transactions, you must prea-aggregate your data in Magic or Data Set View. Then you can return max daily average for a week. Unfortunately it won't respond to filters you'd want to apply at the row level.

  • Hmmm I may be using my terminology incorrectly.

    What I'm trying to do is return the name of the day that, on average, has the highest value.

    Is there a way to incorporate dayname into the window function?

    What we're looking for is the day that, on average, has the highest number of impressions.

    I made an example where I purposefully made Wednesday have the highest count. So if I were to use a beast mode on this dataset, the day that returns the highest value on average would be Wednesday.

    This isn't similar to my data, this is just a small sample.

    My columns would be:

    Impressions (which is the sum of likes, comments, and shares from that day, made using Magic ETL. )

    Day Name (which I created using a beast mode function dayname(date) )

  • MarkSnodgrass
    MarkSnodgrass Portland, Oregon 🔵

    You could try this:

    AVG(COUNT(DAYNAME(date))) OVER (PARTITION BY DAYNAME(date))

    I would also suggest you consider a different visualization and potentially save yourself a lot of work. The calendar chart type is very useful in showing the most popular days of the week. You likely wouldn't have to do any beast modes but just use a count of impressions as your value and the card will do the rest. There is event a week view you can use.


  • @MarkSnodgrass 

    AVG(COUNT(DAYNAME(date))) OVER (PARTITION BY DAYNAME(date))

    this doesn't take into the account the number of impressions. This just finds the day that occurs most.

    What I'm trying to do is find the average number of impressions on a certain day and grab the day that had the highest average.

  • @MarkSnodgrass 

    AVG(COUNT(DAYNAME(date))) OVER (PARTITION BY DAYNAME(date))

    this doesn't take into the account the number of impressions. This just finds the day that occurs most.

    What I'm trying to do is find the average number of impressions on a certain day and grab the day that had the highest average.

Sign In or Register to comment.

Hey, Stranger!

It looks like you're new here. Those who sign in get access to engage with even MORE fire content. To get involved, click one of these buttons!