Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Average MTD - current month - nightly data refresh

Updated: 

 

Hi!

 

I'm trying to calculate the avergae Month To Date record counts for the following scenario:

 

* Data set is refreshed nightly and record counts will be updated.

 

1) On Day 1: May 25th - The record count (20) is the same as the MTD average

2) On Day 2: May 26th - The record count is updated (16). Now MTD is average of previous day and current day counts.

3) On Day 3: May 27th - The record count is updated (24). Now MTD is average of previous 2 days and current day counts etc..

4) This continues till May 31st. The value on May 31st will be retained as the average value of May.

5) On June 1st, again the current day count = MTD average and it continues #2 ...

 

Current DateDaily Record CountMonthly Avg CountMonthly Avg Count (Formula in Excel)
5/25/20202020=SUM($D$2:$D2)/COUNT($D$2:$D2)
5/26/20201618=SUM($D$2:$D3)/COUNT($D$2:$D3)
5/27/20202420=SUM($D$2:$D4)/COUNT($D$2:$D4)
5/28/20202020=SUM($D$2:$D5)/COUNT($D$2:$D5)
5/29/20202220=SUM($D$2:$D6)/COUNT($D$2:$D6)
5/30/20202221=SUM($D$2:$D7)/COUNT($D$2:$D7)
5/31/20202221=SUM($D$2:$D8)/COUNT($D$2:$D8)
6/1/20202424=SUM($D$9:$D9)/COUNT($D$9:$D9)
6/2/20202022=SUM($D$9:$D10)/COUNT($D$9:$D10)
6/3/20202221=SUM($D$9:$D11)/COUNT($D$9:$D11)

 

Thank you!

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      I think my constraint is that:

      I need the value to be updated based on data refresh. E,g, Today's count is 20 and tomorrow's 24. 

      So do I need to have the 20 stored some place?

       

      E.g. This will work if you want to use it on a filtered date range.

      Rolling Average_Count = AVERAGEX(FILTER(ALLSELECTED(Dates),Dates[Date] <=MAX(Dates[Date])),[DocCount])

       

      I tried to update with current date to get MTD average but it didnt work.

       

       

      Is this clear?

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Anonymous 

        You can try with Today(): 

         

        Rolling Average_Count = AVERAGEX(FILTER(ALLSELECTED(Dates),Dates[Date] <=Today(),[DocCount])

         

         

        Paul Zheng _ Community Support Team
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.