4 Replies Latest reply: Nov 21, 2016 8:42 PM by Sunny Talwar RSS

    Use aggr to calculate seven day average

    Xinzhen Wang

      Hello,

       

      I need to calculate a last seven-day average by selection of date.

       

      I used the following calculation but doesn't seem to give me the desired result.It only work if I make no selection (in this case will calculate last 7-day average from max(event_date). Or I have select all seven days in order for it to render the correct answer. Please help!

       

      avg(aggr(sum({$<event_date={">$(=date(max(event_date)-7,'YYYY-MM-DD'))<=$(=max(event_date))"}>}usercnt),event_date))

       

      Xinzhen