Forum Discussion
Line chart with YTD Years based on Slicer selection
- 1 year ago
Thanks. This is fixed now. created a measure instead of a table for capturing the years.
skasu Create a dynamic table for the selected year and the previous year:
YearsTable =
VAR SelectedYear = SELECTEDVALUE('Date'[Year])
RETURN
FILTER(
ADDCOLUMNS(
CALENDAR(DATE(SelectedYear - 1, 1, 1), DATE(SelectedYear, 12, 31)),
"Year", YEAR([Date])
),
[Year] = SelectedYear || [Year] = SelectedYear - 1
)
Set the YearsTable as the data source for your line chart.
Use the Year column from the YearsTable for the X-axis.
Use your measure for YTD counts for the Y-axis.
Create a measure for YTD counts:
DAX
YTDCount =
CALCULATE(
SUM('YourDataTable'[CountColumn]),
DATESYTD('Date'[Date])
)
Add a slicer to your report and set it to filter by the Year column from your Date table.
Ensure that the slicer is affecting the YearsTable and the line chart.
Hi Bhanu,
Thanks for the response.
Created the above YearsTable but showing blank when displaying the Year. Tried creating a measure for SELECTEDVALUE('Date'[Year]) in YearsTable and it was displaying the selected year.
- skasu1 year agoFrequent Visitor
Thanks. This is fixed now. created a measure instead of a table for capturing the years.