cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III

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

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

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

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors