Forum Discussion

Joshi_M's avatar
Joshi_M
Helper I
5 years ago
Solved

MOVING AVERAGE -3 weeks

Hi,

I am a fair user of Power BI but struggling with creating a measure for calculation of Moving avarage  across weeks

Below is a example of Matrix visual in Power BI.

I want to use a measure to calculate the moving average of demand across 3 weeks.

Moving average Demand, Measure in below example should be for week 6 = 60/3=20, Week 7= 50/3 = 16.6 and so on.

The measure will be used further to calculate days. Constraints as below Data is from direct query.

  1. Some slicers are already selected
  2. Year and week in text format
  3. Field available in Direct query in date format is (First day of the week)
  4. Fiels available for index weeks which is filtered for avlues between 0 &11
  5. Formula tried  MAD -3 weeks = CALCULATE( AVERAGEX(ZBE_12WEEK_DEMAND_AP,ZBE_12WEEK_DEMAND_AP[Demand in To]), DATESINPERIOD( ZBE_12WEEK_DEMAND_AP[First Day of Week], LASTDATE(ZBE_12WEEK_DEMAND_AP[First Day of Week]), 21, DAY ) )
  6. Result of above formuala is the same demand as shown.

Kindly help to resolve . 

 

Year Week2021.062021.072021.082021.092021.12021.112021.122021.132021.14
Material A         
Demand 400203001040030
Stock202010302010202010
Days4#DIV/0!47#DIV/0!74#DIV/0!2
Material B         
Demand 500203001050030
Stock252510302510252510
Days4#DIV/0!47#DIV/0!74#DIV/0!2

 

Regards

Joshi M

 

2 Replies