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
dv_
Regular Visitor

Dynamically select past N days of dates & table rows based on Slicer

Hello, Power BI Community,

 

Long story short, I am trying to display a table that shows the N days of dates & table rows based on Slicer. I've spent the past two days trying various solutions presented here (some of them below) to no avail.

 

Link to sample file here: https://drive.google.com/file/d/1y81osptUSc9qwE7DvdR0hQbmANZvEJS6/view?usp=sharing 

 

The requirement is to filter and only show the past N days from the filter selection, as per the below picture. There's an additional table that cannot be changed. 

 

dv__0-1715895535399.png

 

These were the posts that seemed to be closest to my issue, but I still couldn't make it work. Thanks, @PaulDBrown and @v-yueyunzh-msft for suggestions.

 @PaulDBrownshow pat 7 days from selected date - Microsoft Fabric Community

@v-yueyunzh-msft : Solved: Re: Only show Last X days based on date slicer sel... - Microsoft Fabric Community

 

Any suggestions / help would be hugely appreciated.

 

Thank you.

2 ACCEPTED SOLUTIONS
kpost
Super User
Super User

 

See attached dv_solution.pbix report with a working solution.  I also downloaded your file and implemented the same strategy, essentially fixing the issue, 'Sample Report.pbix'

 

1) I created a copy of the fact table with no active relationship to the Date Dimension table. (You may choose to use SELECTCOLUMNS instead, only including the fields you want in the copy table, to reduce the size of your semantic model).

 

2) Used fields from the COPY table in the table visual.

 

3) Turned ON visual level interactions between the date slicer and the table in question

 

4) Added a visual-level filter that depends upon the selected date, and goes back 7 days

 

In the file dv_solution.pbix I also added an "N" filter, to allow you to go back N days, because I wasn't sure whether you wanted that hard-coded or not.

 

Here's the filter:

 

 

 

Visual Level Filter = 
VAR selected_date = selectedvalue('Calendar'[Date])

var table_Date = selectedvalue(copy_table[For Date])

return 
IF(table_Date >= selected_date - 7 && table_Date <= selected_date , 1, 0)


 

 

Hopefully this helps.

 

proof.PNG

Mediocre Power BI advice, but it's free///

View solution in original post

dv_
Regular Visitor

Beautiful! Thank you so much! Now I have to do this 12 more times, for my entire report. 🙂

But I can only replicate the columns I need, which will make it easier and lighter on the model.

 

Thanks again, @kpost .

View solution in original post

2 REPLIES 2
kpost
Super User
Super User

 

See attached dv_solution.pbix report with a working solution.  I also downloaded your file and implemented the same strategy, essentially fixing the issue, 'Sample Report.pbix'

 

1) I created a copy of the fact table with no active relationship to the Date Dimension table. (You may choose to use SELECTCOLUMNS instead, only including the fields you want in the copy table, to reduce the size of your semantic model).

 

2) Used fields from the COPY table in the table visual.

 

3) Turned ON visual level interactions between the date slicer and the table in question

 

4) Added a visual-level filter that depends upon the selected date, and goes back 7 days

 

In the file dv_solution.pbix I also added an "N" filter, to allow you to go back N days, because I wasn't sure whether you wanted that hard-coded or not.

 

Here's the filter:

 

 

 

Visual Level Filter = 
VAR selected_date = selectedvalue('Calendar'[Date])

var table_Date = selectedvalue(copy_table[For Date])

return 
IF(table_Date >= selected_date - 7 && table_Date <= selected_date , 1, 0)


 

 

Hopefully this helps.

 

proof.PNG

Mediocre Power BI advice, but it's free///

dv_
Regular Visitor

Beautiful! Thank you so much! Now I have to do this 12 more times, for my entire report. 🙂

But I can only replicate the columns I need, which will make it easier and lighter on the model.

 

Thanks again, @kpost .

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
Top Kudoed Authors