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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-yetao1-msft
Community Support
Community Support

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
v-yetao1-msft
Community Support
Community Support

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

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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