Forum Discussion
Rolling average with adjustable time frame
I'm having issues creating a measure to calculate the average over the past X days for a specific account. In the initial Data I have multiple rows per day for several accounts with a specific value recorded for each account, each day. The data is over a year and I need to come up with an average amount looking back X days, then compare the current days value to the average amount over the adjustable period. to calculate the average amount I have a query that almost works, it just looks at every day and creates an average instead of averaging over the days in the spreadsheet (which excludes weekends and holidays). How would I be able to fix this issue? I need to create a matrix which will show every value and then count the amount of times the specific day breaks the specified average value.
AverageAmountOverXDays =
VAR SelectedDays = SELECTEDVALUE(DaysP arameter[Days Parameter])
RETURN
CALCULATE(
AVERAGE('Table'[Amount]),
DATESINPERIOD('Date'[Date], MAX('Date' [Date]), -SelectedDays, DAY)
)
I also have a reference calendar that contains only dates from the data and a count to rank them. I couldn't figure out how to take advantage of it though.
8 Replies
- lbendlin
Super User
Sounds like Numeric Parameters can handle this for you. How far back should X be?
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- BryantSturnRegular Visitor
For the attached file I would need a rolling average that only includes dates found in the data and is set by the parameter
If you need anything else please let me know!
- lbendlin
Super User