Forum Discussion
Create 52 and 9 Week Sales Average based on Selected Date
I have a weekly Product Sales table for the last year. In the report, I have a Filter where you can select the weekend that you'd like to see as the max weekend in the table. My table shows the last 9 weeks of sales based on the Selected Weekend Date but I'd also like to show the the 9 Week Average AND the last 52 Week Average in the table both based on the Selected Date.
Sales [Product Code], Sales [Weekend], Sales [Sales]
And I do have a Date table Calendar [weekend]
1 Reply
- amitchandak
Super User
RAdams ,Have these new columns in Date Table, Week Rank is Important in Date/Week Table. It can be based on week end date
Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW formatMeasure like this can help
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))Avg Last 9 weeks = CALCULATE(Averagex(Values('Date'[Week Rank]), [orders ]) , FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-8 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
//use 9 if needed
Get week start and end of your choice
Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Power-BI-Turning/ba-p/1187482
https://medium.com/chandakamit/cheat-sheet-any-weekdays-week-start-date-just-one-variable-apart-6b2e6f593958Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8