Forum Discussion

Silvia_Gulu_BXL's avatar
Silvia_Gulu_BXL
Frequent Visitor
2 years ago
Solved

Weighted moving average

Hello, I have a table with the demand per month:

 

I want to calculate the moving average but with weighted average like below:

Forecasted_demand=(M1*1+M2*2+M3*3)/6

(M1: 3 months ago, M2: 2 months ago, M3: previous month)

 

Could you help to write the DAX measure to get it?

 

Thank you in advance!

 

Kind regards,

Silvia

 

 

 

  • Hello Silvia_Gulu_BXL 

     

    output : 

    kindly use the following measure : 

    moving weighted average =
     var current_month =  max(Table30[date])

     var M3 =  
     CALCULATE(
        SUM(Table30[actual demand]),
        Table30[date] = EDATE(current_month,-1)
     )
    var M2 =
     CALCULATE(
        SUM(Table30[actual demand]),
        Table30[date] = EDATE(current_month,-2)
     )
    var M1 =
     CALCULATE(
        SUM(Table30[actual demand]),
        Table30[date] = EDATE(current_month,-3)
     )


    var resl = ( (M3*3) +  (M2*2) + (M1*1)) / 6


    RETURN resl

     

     

     

     let me know if this works for you . 

     

    If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. I would appreciate hitting that kudos button 👍🤠

     

2 Replies

  • Daniel29195's avatar
    Daniel29195
    Community Champion

    Hello Silvia_Gulu_BXL 

     

    output : 

    kindly use the following measure : 

    moving weighted average =
     var current_month =  max(Table30[date])

     var M3 =  
     CALCULATE(
        SUM(Table30[actual demand]),
        Table30[date] = EDATE(current_month,-1)
     )
    var M2 =
     CALCULATE(
        SUM(Table30[actual demand]),
        Table30[date] = EDATE(current_month,-2)
     )
    var M1 =
     CALCULATE(
        SUM(Table30[actual demand]),
        Table30[date] = EDATE(current_month,-3)
     )


    var resl = ( (M3*3) +  (M2*2) + (M1*1)) / 6


    RETURN resl

     

     

     

     let me know if this works for you . 

     

    If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. I would appreciate hitting that kudos button 👍🤠