Forum Discussion
Moving Averages for Measures
I wanted to create a moving average line and plot it against my measure that rebases my prices to 100. My moving average measure originally did work with my original Return index column, however, it did not work with my measure for rebasing the Return index. Was wondering why this so....
Moving Average Formula (50D):
50D MAV = CALCULATE(
AVERAGEX('RI','RI'[Asset Price Rebased]),
DATESINPERIOD('DateTable'[Date],
LASTDATE('DateTable'[Date]),
-50,
DAY))
Rebasing DAX Measure Formula:
Asset Price Rebased = VAR Date_Index = CALCULATE(MIN('RI'[Date]),ALLSELECTED('RI'))
Return
(SUM('RI'[Return Index]) / (CALCULATE(SUM(RI[Return Index]), 'RI'[Date] = Date_Index))) * 1003 Replies
- amitchandak
Super User
WestWinter , Try lik
50D MAV = CALCULATE(
(SUM('RI'[Return Index]) / (CALCULATE(SUM(RI[Return Index]), 'RI'[Date] = Date_Index))) * 100,
DATESINPERIOD('DateTable'[Date],
LASTDATE('DateTable'[Date]),
-50,
DAY))But better to divide it count of index or date
Example
50D MAV = CALCULATE(
divide(SUM('RI'[Return Index]) , (CALCULATE(Count(RI[Return Index])))) * 100,
DATESINPERIOD('DateTable'[Date],
LASTDATE('DateTable'[Date]),
-50,
DAY))- WestWinter
Helper II
Tried your 1st/2nd formula but does not work 😞
- v-easonf-msft
Community Support
Hi , WestWinter
Is it possible to share that sample pbix with me to test, or show how your table looks like. I am curious what the error message is. Why it doesn't work?
Best Regards,
Community Support Team _ Eason