Getting the last N data giving the whole data

I have the following measure :

Last N weeks Cases = CALCULATE([Total Cases],FILTER(all(‘Date’),‘Date’[Week Rank]>=(min(‘Date’[Week Rank])- [WeekRankSelected])&& ‘Date’[Week Rank]<=max(‘Date’[Week Rank])))

Where [WeekRankSelected] is the selected value of a parameter :

WeekRankSelected = SELECTEDVALUE ( WeekRank[WeekRank] )

I already added to my Date dimension, these following calculated columns :

Week Start date = ‘Date’[Date] + -1WEEKDAY(‘Date’[Date],2)+1
Week End date = ‘Date’[Date] + 7 –1
WEEKDAY(‘Date’[Date],2)
Week Rank = RANKX(all(‘Date’),‘Date’[Week Start date],ASC,Dense)

The problem is when I try to select a week rank it is always giving me the same values :

Capture.PNG

My Date data starts from 01/01/2020 to 31/12/2021

I am following this tutorial.

Hi @amira.bedhiafi.pro

Please share sample Power BI file for us to look further.

Hi @amira.bedhiafi.pro, we’ve noticed that no response has been received from you since the 7th of February. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!

Hi @amira.bedhiafi.pro, a response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box. We’ve recently launched the Enterprise DNA Forum User Experience Survey, please feel free to answer it and give your insights on how we can further improve the Support forum. Thanks!