Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Signle select week slicer, but showing line graph for last 7 weeks (relative to slicer)

Hi,

I have a relative simple requirement, but I'm struggling with the implementation, so can use some help.

 

I have data with 20 weeks of sales data. In my report I want to have 1 slicer where I can select a week (ie. week 18). 

Next to that I would like to show a card with the sales for that week. So far so good.

But then I would like to add a line graph with the last 7 weeks of sales. This doesn't work because of the slicer filtering on week 18.

I have tried to disable the interactions between the slicer and the line graph. But then I can't show the last 7 weeks relative to the selected week anymore.

I have also tried to work with a relative filter on the visual to only look at data in the last 7 weeks, but this is 'relative to today', not to the week a user selected in the slicer.


So unsure what else I can try to fix this.

In short: the x axis of the line graph needs to be wider than the slicer value (it's value + the six weeks before that).

 

Like the simple example below:

Week slicer issue.PNG

 

I would appreciate help on suggestions how to implement this.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , When You select one date/week and need more than that, you need an independent date/week table

 


//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Week Rank])
var _min = _max -7
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))

 

Week rank is column in both date tables- rank on YYYYWW

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('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)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks a lot @amitchandak , this was very useful!

amitchandak
Super User
Super User

@Anonymous , When You select one date/week and need more than that, you need an independent date/week table

 


//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Week Rank])
var _min = _max -7
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Week Rank] >=_min && 'Date'[Week Rank] <=_max))

 

Week rank is column in both date tables- rank on YYYYWW

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('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)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors