Forum Discussion
dynamic line chart
Please follow the below steps:
1. Create a Date table with a column: Date[MonthYear] (formatted like "YYYY-MM" or a proper date)
2. Create a measure to control the dynamic range
Sales (Selected + Prev 2 Months) =
VAR SelectedMonth =
SELECTEDVALUE('Date'[MonthYear]) -- e.g., "2024-03"
VAR SelectedDate =
CALCULATE(
MAX('Date'[Date]),
'Date'[MonthYear] = SelectedMonth
)
VAR StartDate =
EDATE(SelectedDate, -2)
VAR IsMonthSelected =
NOT ISBLANK(SelectedMonth)
RETURN
IF(
IsMonthSelected,
CALCULATE(
[Total Sales],
FILTER(
ALL('Date'),
'Date'[Date] >= StartDate &&
'Date'[Date] <= SelectedDate
)
),
[Total Sales] -- fallback: show all months
)
🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!
Hi grazitti_sapna ,
I have tried your approach however nothing is happening once i click on any data point on visual
please see below pbix
https://drive.google.com/file/d/11J2eg84_GyyPVD0Thtn6wRHtO0JrPwrS/view?usp=drive_link