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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.