Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
Solved! Go to 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.
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! |
@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.
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! |
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.
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! |
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
18 | |
18 | |
17 | |
16 |
User | Count |
---|---|
29 | |
27 | |
20 | |
15 | |
14 |