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
Vaishali04
Helper II
Helper II

Show 30 days data in visual before the date selected in date slicer

Hi All,

 

I have a date slicer and a line chart. My requirement is on selecting a date in date slicer , 30 days of data should be displayed in line chart ahead of date selected in date slicer.

 

If someone came across same scenario. Please suggest the solution.

 

Regards

Vaishali

1 ACCEPTED SOLUTION

@Vaishali04 , as you wish, I attached a pbix file for your reference.

It's a simplified project I was once engaged in. It's with more flexibilities to display previous 1 ~ 30 days before a chosen date.

Screenshot 2020-12-02 115538.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Vaishali04 , You can get the last 30 days like the example with help from the date table 

Rolling 30 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date],-12,DAY)))

 

But this will not give trend for last 30 Days. Follow the approach in the video

https://www.youtube.com/watch?v=duMSovyosXE

@amitchandak  Thanks for the logic 

 

The logic is working fine but still the chart is showing data only for the date selected in the slicer and not of past 12 or 30 days. 

CNENFRNL
Community Champion
Community Champion

Hi, @Vaishali04 , the solution is a bit tricky given the fact that filter (selection of a date in the slicer) propogates from slicer to chart,

New Measure =
VAR __date_selected = MAX ( 'Calendar'[Date] ) // assuming there exists a calendar table in your model, and Calendar[Date] is sliced

VAR __period = DATESINPERIOD ( 'Calendar'[Date], __date_selected, -30, DAY )

VAR __inbetween =
    CALCULATE ( MAX ( factTable[Date] ), ALL ( 'Calendar'[Date] ) ) IN __period // slcier must be removed in order to keep all other dates in sight

RETURN
    IF ( __inbetween, [Old Measure] )

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL 

 

I tried you logic but it is giving me only two dates. It will be more helpful , if you could share a sample PBI file for the same.

@Vaishali04 , as you wish, I attached a pbix file for your reference.

It's a simplified project I was once engaged in. It's with more flexibilities to display previous 1 ~ 30 days before a chosen date.

Screenshot 2020-12-02 115538.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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.

Top Solution Authors