Forum Discussion
get the last N weeks data
I have the following model :
I want to calculate using DAX the Last N Weeks Covid cases excluding the current week. The numbers should change dynamically with the What-if-Parameters selection. The parameter starting from 2 and increasing incrementally by 1 till 28 weeks.
This is my expected output :
amirabedhiafi , Refer my post on WOW, You can create Week Rank in You date table and Use that.
Last 2 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-2 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
The above two can come from what if measure
Power 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
5 Replies
- amitchandak
Super User
amirabedhiafi , Refer my post on WOW, You can create Week Rank in You date table and Use that.
Last 2 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-2 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
The above two can come from what if measure
Power 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- amirabedhiafi
Impactful Individual
How can I link Last 2 weeks to the parameter?
- amirabedhiafi
Impactful Individual
amitchandak I modified it to :
Last2weeks = CALCULATE(SUM('COVID Data'[COVID Cases]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-WeekRank[WeekRank Value] && 'Date'[Week Rank]<=max('Date'[Week Rank])))after creating the Week Rank Calculated Column in the Dimension Date.But I can't see the value : - whatisdata96
Helper I
How do you get week rank once you have WeekEND Date established in your date table?
- Deepanshi_RankaRegular Visitor