Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
1 year ago

Moving Average Per Day

Hello everyone

I'm working on a daily average calculation in Power BI, but currently what I get is a sum of the values per day, rather than the average.

My goal is that, as the days progress, the values accumulate and divide them by the number of days elapsed, to obtain a moving average.

Can you tell me what adjustments I need to make to my formula or approach to achieve this?

Thank you in advance!

3 Replies

  • Hi,

    This measure pattern should work

    Moving average = averagex(summarize(calculatetable(calendar,datesbetween(calendar[date],eomonth(min(calendar[date]),-1)+1,min(calendar[date]))),calendar[date],"A",[Total]),[A])

    If this does not work, then share the download link of the PBI file.  Show the problem and the expected result there.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi grgilardi,

     

    Please try this measure:

    Promedio Movil = 
    VAR __DiasHastaHoy = MAX ( 'Date'[Date] )
    VAR __values_accumulate = CALCULATE(SUM('Inventarios'[Faltantes]),'Date'[Date]<=__DiasHastaHoy)
    VAR __days = COUNTROWS(FILTER(ALL('Date'),'Date'[Date]<=__DiasHastaHoy))
    RETURN
    DIVIDE(__values_accumulate,__days)

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum