Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have the following line chart where the X-Axis is controlled by a Parameter (Age or Weeks). What I would like to happen is if Weeks is selected, then it displays 1 full year (depending on which year is selected from another slicer (Slicer is called "Year" and currently has the following values: 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 and 2024)
So, for example, if the user selects "2023" in the Year slicer, then the X-axis for Weeks would display all the weeks for 2023 only. I currently am using the filter but I have to do that manually:
Can I build in a DAX measure that would filter it each time to the correct year?
Solved! Go to Solution.
Hi @rmcgrath ,
Try the following expression:
FilteredWeeks =
VAR SelectedYear = SELECTEDVALUE('Year'[Year])
VAR SelectedParameter = SELECTEDVALUE('Parameter'[Parameter])
RETURN
IF(
SelectedParameter = "Weeks",
CALCULATE(
SUM('YourTable'[Value]),
FILTER(
'YourTable',
YEAR('YourTable'[Date]) = SelectedYear
)
),
SUM('YourTable'[Value])
)
Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @rmcgrath ,
Try the following expression:
FilteredWeeks =
VAR SelectedYear = SELECTEDVALUE('Year'[Year])
VAR SelectedParameter = SELECTEDVALUE('Parameter'[Parameter])
RETURN
IF(
SelectedParameter = "Weeks",
CALCULATE(
SUM('YourTable'[Value]),
FILTER(
'YourTable',
YEAR('YourTable'[Date]) = SelectedYear
)
),
SUM('YourTable'[Value])
)
Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 27 |
| User | Count |
|---|---|
| 135 | |
| 102 | |
| 67 | |
| 65 | |
| 56 |