Forum Discussion

marama's avatar
marama
Helper I
3 years ago
Solved

How to filter for multiple slicer values?

So I have a table with teams (team_id, team_name), and i have a table with projects (project_id, project_name, owner_team_id, developer_team_id). So each project has a team owning the project, and a team developing the project. 
I need to have a teams slicer with multiple selections, and a resulting table showing projects where selected teams are either an owner_team_id or developer_team_id , i.e. all projects relevant to a team shold be listed. Any idea how I can achieve it using DAX?
I've tried FILTER and SELECTEDVALUES, but I didn't get anywhere ;(

The real world case is a bit more compley, with date slicer as well, so projects table is actually already filtered with date slicer, so I need to apply FILTER function on already fileterdd table (with date slicer).

(how can I attach a pbix file to this post?)

  • You could create a measure like

    Team belongs to project =
    VAR CurrentTeams =
        VALUES ( 'Teams'[Team ID] )
    VAR CurrentProjectOwner =
        SELECTEDVALUE ( 'Project'[owner team ID] )
    VAR CurrentProjectDev =
        SELECTEDVALUE ( 'Project'[dev team ID] )
    RETURN
        IF (
            CurrentProjectOwner
                IN CurrentTeams
                || CurrentProjectDev IN CurrentTeams,
            1
        )
    

    and then use that as a visual level filter on the table to only show when the value is 1

3 Replies

  • You could create a measure like

    Team belongs to project =
    VAR CurrentTeams =
        VALUES ( 'Teams'[Team ID] )
    VAR CurrentProjectOwner =
        SELECTEDVALUE ( 'Project'[owner team ID] )
    VAR CurrentProjectDev =
        SELECTEDVALUE ( 'Project'[dev team ID] )
    RETURN
        IF (
            CurrentProjectOwner
                IN CurrentTeams
                || CurrentProjectDev IN CurrentTeams,
            1
        )
    

    and then use that as a visual level filter on the table to only show when the value is 1

    • marama's avatar
      marama
      Helper I

      Thank you. Weird, I had a similar code, but my code returned true/false, and I wans't able to filter the results. Using 1/blank as you suggest, can be filtered. I wasn't aware of the boolean limitation in filter.

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi marama ,

     

    Whether the advice given by johnt75  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly.

     

    If not, you can refer to the following link and provide the necessary test information to facilitate me to answer your questions as soon as possible.

    How to Get Your Question Answered Quickly - Microsoft Power BI Community


    Best Regards,
    Henry