Selecting multiple lines in a line charts using slicer

I am trying to display hide multiple lines in a line chart using a slicer. When the user selects option A they should see one line, if they select A and B they should see to lines

I cannot change the data structure, so potentially a SWITCH function or any other DAX measure would be ideal
Sample.xlsx (8.8 KB)
sample_bi_line_graph.pbix (44.6 KB)

I have seen a few videos, but am unable to get the DAX to work. Please help, I have attached a sample of pbix and data file for reference

Hi @alang.

To restrict the values that are shown in a visual, one way is to use an IF statement to check if a particular selection has been made, then return the desired value, otherwise return blank.

Here’s an example:

A Interval % =
IF(
    "A" IN
    VALUES( SlicerValues[ID] ),
        SUM( Sheet1 [A Interval %] ),
        BLANK()
)

It would work easier (and by default, so with no DAX code) if you had a proper data model with fact and dimension tables joined by a one-to-many relationship.

Hope it helps.
Greg
eDNA Forum - Lines by Slicer Selections.pbix (45.4 KB)

Thank you @Greg! This was extremely helpful. I agree that a proper data model would be best suited to address this.