cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors