Quantcast
Channel: Desktop topics
Viewing all articles
Browse latest Browse all 217177

Moving average of previous months after filtering for a single month via Slicer

$
0
0

Good Day,

 

Really need help in finding out how to get the moving average of previous months after filtering for a single month. I have come across some solutions in the forums but they do not seem to be working in my case for some reason (e.g., I cannot seems to clear the filter implemented by the slicer).

 

I am try to achieve the following, based on the data below (the data has been simplified and replaced with dummy data)

 

Current, the formulas I have tried to achieve this with are:

 

MA of Prev 3 months = CALCULATE(AVERAGE('Website Data'[Website Users]),DATESINPERIOD('Website Data'[StartOfMonthDate],DATEADD(LASTDATE('Website Data'[StartOfMonthDate]),-1,MONTH),-3,MONTH))

 

(This failed as soon as I filtered for that one month value)

 

I also tried an alternative solution from http://community.powerbi.com/t5/Desktop/Sum-year-and-previous-year-from-that-year-selected-from-filtered/m-p/33252/highlight/true#M11754 but I think I may be doing something wrong

 

MaxYearMonth = MAX('Website Data'[Month of Year])

MA of Prev 3 month v2 = CALCULATE(SUM('Website Data'[Website Users]), FILTER('Website Data', 'Website Data'[Month of Year]=[MaxYearMonth]-1 || 'Website Data'[Month of Year]=[MaxYearMonth]-2 || 'Website Data'[Month of Year]=[MaxYearMonth]-3))

 

The (failed) results are seen below:

 

I would be grateful if anyone could see how I could implement this. It has been driving me nuts for the past week or 2. Here is the work file for your convenience: https://drive.google.com/open?id=0BymvfSPfXzNFRC1HRkNBUjdZbFU 

 

Cheers,

Joe


Viewing all articles
Browse latest Browse all 217177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>