cancel
Showing results for
Did you mean:

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

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
Community Champion

@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.

 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!
5 REPLIES 5
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

Helper II

@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.

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

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.

Community Champion

@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.

 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!

Announcements

#### Power BI Monthly Update - November 2023

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

#### Fabric Community News unified experience

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

#### 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