Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to create a moving average total.

Hi, 

 

I am looking to create a moving average totalt for the last month. 

 

Can someone please help?

 

PowerBiGuy1234

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    If you just want to get the value of the last month, I suggest you use PREVIOUSMONTH() like this:

    PreviousMonth = CALCULATE(AVERAGE('Table'[Value]),PREVIOUSMONTH('Table'[Date]))

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

     

    Try if these type of measures can help

     

    M1= avergageX(values('Date'[Month]), calculate(sum(Table[Value])))

     

    Moving Avg = calculate([M1], filter(allselected('Date'), 'Date'[Date]< min('Date'[Date]))) //till last month

    or

    Moving Avg = calculate([M1], filter(allselected('Date'), 'Date'[Date]<= max('Date'[Date]))) //till this month

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    If you just want to get the value of the last month, I suggest you use PREVIOUSMONTH() like this:

    PreviousMonth = CALCULATE(AVERAGE('Table'[Value]),PREVIOUSMONTH('Table'[Date]))

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.