Forum Discussion

mattlawrence's avatar
mattlawrence
Frequent Visitor
8 years ago
Solved

Filter a visual by values of another column

In a sports dataset (2 teams) I have a variety of different columns which show type of actions and performance measures. I need to be able to view the opposition's actions in a visual when filtering by one team. In my dataset there is Team and Opposition Team. Is it possible to use the values of Opposition Team (multiple teams in some cases) and apply a filter using DAX of these values? The fixtures are filtered by a slicer.

 

For example:

 

I wish to visualise the distance the striker of LA Galaxy runs in 5 (user selected) games. But in another visual need to visualise the distance the striker runs of all opposing teams in these 5 matches.

 

Many thanks,

 

Matt

  • v-danhe-msft's avatar
    v-danhe-msft
    8 years ago

    Hi mattlawrence,

    Based on my test, you could refer to below test:

    Create a new table to list the distinct team_id:

    New table = DISTINCT('sample data for community'[team_id])

    Create a measure:

    Opposite meters = CALCULATE(SUM('sample data for community'[Metres]),FILTER('sample data for community','sample data for community'[team_id]<>SELECTEDVALUE('New table'[team_id])))

    Now you could use the 'New table'[team_id] as slicer to show the opposite meters:

     

    You could also download the pbix file to have a view.

     

    Regards,

    Daniel He

5 Replies

  • v-danhe-msft's avatar
    v-danhe-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi mattlawrence,

    Could you please share some sample data to have a test and post your desired result if possible?

     

    Regards,

    Daniel He

    • mattlawrence's avatar
      mattlawrence
      Frequent Visitor

      Hi Daniel,

       

      Thanks for your help, it is highly appreciated.

       

      Here is some very simplified sample data:

       

      IDFXIDteam_idMatchTimeactionMetresPosIDopp_id
      1LATRLA27Run3StrikerTR
      2LATRLA32Run7MidfieldTR
      3LATRLA35Run3DefenseTR
      4LATRLA69Run6StrikerTR
      5LATRTR8Run7MidfieldLA
      6LATRLA50Run4DefenseTR
      7LATRLA69Run5StrikerTR
      8LATRTR42Run14MidfieldLA
      9LATRTR63Run8DefenseLA
      10LATRTR15Run11StrikerLA
      11LATRTR21Run4MidfieldLA
      12LATRLA43Run1DefenseTR
      13LATRLA24Run6StrikerTR
      14LATRTR57Run16MidfieldLA
      15LATRTR55Run20DefenseLA
      16LATRTR8Run3StrikerLA
      17LATRTR51Run16MidfieldLA
      18LATRLA18Run13DefenseTR
      19LATRLA47Run16StrikerTR
      20LATRTR11Run6MidfieldLA
      21LATRTR39Run18DefenseLA
      22LATRTR33Run15StrikerLA
      23LATRTR42Run13MidfieldLA
      24LATRTR39Run4DefenseLA
      25LAVNLA90Run10StrikerVN
      26LAVNLA26Run4MidfieldVN
      27LAVNLA11Run15DefenseVN
      28LAVNLA7Run19StrikerVN
      29LAVNVN43Run10MidfieldLA
      30LAVNLA26Run2DefenseVN
      31LAVNLA90Run8StrikerVN
      32LAVNVN22Run12MidfieldLA
      33LAVNVN32Run11DefenseLA
      34LAVNVN17Run11StrikerLA
      35LAVNVN64Run4MidfieldLA
      36LAVNLA84Run9DefenseVN
      37LAVNLA0Run1StrikerVN
      38LAVNVN5Run7MidfieldLA
      39LAVNVN64Run3DefenseLA
      40LAVNVN15Run13StrikerLA
      41LAVNVN78Run7MidfieldLA
      42LAVNLA20Run6DefenseVN
      43LAVNLA60Run19StrikerVN
      44LAVNVN28Run3MidfieldLA
      45LAVNVN57Run13DefenseLA
      46LAVNVN9Run11StrikerLA
      47LAVNVN2Run5MidfieldLA
      48LAVNVN72Run8DefenseLA
      49TRVNTR32Run6StrikerVN
      50TRVNTR36Run7MidfieldVN
      51TRVNTR28Run8DefenseVN
      52TRVNTR43Run17StrikerVN
      53TRVNVN49Run13MidfieldTR
      54TRVNTR3Run12DefenseVN
      55TRVNTR65Run7StrikerVN
      56TRVNVN5Run4MidfieldTR
      57TRVNVN57Run15DefenseTR
      58TRVNVN45Run1StrikerTR
      59TRVNVN62Run6MidfieldTR
      60TRVNTR58Run17DefenseVN
      61TRVNTR34Run8StrikerVN
      62TRVNVN64Run6MidfieldTR
      63TRVNVN24Run12DefenseTR
      64TRVNVN63Run4StrikerTR
      65TRVNVN40Run20MidfieldTR
      66TRVNTR19Run8DefenseVN
      67TRVNTR49Run1StrikerVN
      68TRVNVN85Run13MidfieldTR
      69TRVNVN78Run4DefenseTR
      70TRVNVN82Run1StrikerTR
      71TRVNVN19Run16MidfieldTR
      72TRVNVN16Run3DefenseTR

       

      FXIDREF
      LATRJones
      LAVNJones
      TRVNMatthews

       

       

       

      There is a relationship between FXID.

       

      MatchData          FixtureData

      FXID             *:1    FXID

       

      What I require in the blank box is the data for the opposition.

       

      For instance when LA are playing I need to be able to show their meters and the opposition meters. This could be when the user selects a single team from the opposition or the user wishes to view how the oppositon perform generally against LA.

       

      When filtering by team_id (which the user will be doing) all the data for the opposition is filtered out. I have tried using DAX functions like ALL, ALLSELECTED and SELECTEDVALUE (possibly wrongly) but this is proving difficult. I was wondering if you could help with the DAX or help with another solution.

       

      In the real dataset there are many more slicers used and there are more relationships between the match data and other tables.

       

      PBIX file here: https://drive.google.com/file/d/1xAHB-5sszaiNX6LY1NCFnFIYanuScP0I/view?usp=sharing

       

      Many thanks,

       

      Matt

      • v-danhe-msft's avatar
        v-danhe-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi mattlawrence,

        Based on my test, you could refer to below test:

        Create a new table to list the distinct team_id:

        New table = DISTINCT('sample data for community'[team_id])

        Create a measure:

        Opposite meters = CALCULATE(SUM('sample data for community'[Metres]),FILTER('sample data for community','sample data for community'[team_id]<>SELECTEDVALUE('New table'[team_id])))

        Now you could use the 'New table'[team_id] as slicer to show the opposite meters:

         

        You could also download the pbix file to have a view.

         

        Regards,

        Daniel He

  • v-danhe-msft's avatar
    v-danhe-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi mattlawrence,

    Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

     

    Regards,

    Daniel He