Forum Discussion
12 week average
I have a visual that displays a table with a "Week Ending Tuesday" column as a date and a DAX measure for "Total Accounts Receivable". I need to create a new DAX measure that calculates the 12-week average of the "Total Accounts Receivable" measure. Consider the date filter of financial year that starts in July. Thanks in advance 🙂
1 Reply
- amitchandakSuper User
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW formatLast 12 weeks = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-12 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
For tuesday week
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-6b2e6f593958But in case you need select a date and then show 12 week trend
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Week Rank])
var _min = _max -1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))