Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mattlawrence
Frequent Visitor

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

1 ACCEPTED SOLUTION

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])

1.PNG

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:

1.PNG

 

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

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-danhe-msft
Microsoft Employee
Microsoft 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

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @mattlawrence,

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

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

 Screenshot (6).png

 

 

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

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])

1.PNG

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:

1.PNG

 

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

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.