How to add or remove lines from power BI line chart based on the slicer selected value, if nothing is selected all lines will be shown and if multiple item is selected, only the selected value will be shown.
Slicers:
1. Years - this will be years shown to user to select
2. Type - categorical value shown in the slicer
3. Type 2 - another categorical variable shown to the user.
Note all these tables must be independent from the main data model to avoid filtering the data and what not.
DAX:
in the dax script below we have two logic test, which allows the user to add or remove those categorical line chart from the graph.
the 3rd varible is used in the switch statement.