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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
yslee
Frequent Visitor

Dynamically date query

Hi. In my database, I have 2 columns (date and production) filter by a single date slicer.
I would like to dynamically plot the 7 days back production data based on the single date slicer value. How can I do this?

For example
Slicer date selected: 7th apr 2021
Production data retrieve
1st apr
2nd apr
3rd apr
4th apr
5th apr
6th apr
7th apr
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @yslee ,

You can create a calendar table as a slicer to filter the data in Data table.

Calendar Date = CALENDAR(DATE(2021,04,01),DATE(2021,04,30))

 

Then create a measure to return the 7 days back production data.

last 7 days products = CALCULATE(SELECTEDVALUE('Table'[Product]),FILTER('Table','Table'[Date]>MAX('Calendar Date'[Date])-7 && 'Table'[Date]<=MAX('Calendar Date'[Date])))

 

The effect is as shown:

Ailsa-msft_0-1618362221440.png

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @yslee ,

You can create a calendar table as a slicer to filter the data in Data table.

Calendar Date = CALENDAR(DATE(2021,04,01),DATE(2021,04,30))

 

Then create a measure to return the 7 days back production data.

last 7 days products = CALCULATE(SELECTEDVALUE('Table'[Product]),FILTER('Table','Table'[Date]>MAX('Calendar Date'[Date])-7 && 'Table'[Date]<=MAX('Calendar Date'[Date])))

 

The effect is as shown:

Ailsa-msft_0-1618362221440.png

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@yslee , if you select a date and plot more than that date , you need 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors