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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filtering on two selected values

Hi, All!

 

I do really not know if I am looking at this task from the right angel, so I am really hoping one of you can help. 

 

My goal is, that I would like to select one team in the tabel to the left, then select an opponent in the slicer in the top right, and then get their matchhistory against eachother in the table to the right. 

poulsea_1-1660668234884.png

 

My initial thought was, that I needed to collect the selected value in the slicer, and then filter on whether both the selected teams are included in the Game ID, but I truly do not know if this is the right way to handle it.

 

My dataset looks like the below, where there is multiple rows with the same Game ID with different information in each column. 

poulsea_2-1660668502853.png

 

Any suggestions to solve this matter are kindly received. 

Thanks in advance. 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1662011263424.png

Please try:

First, create a new table of all the teams for slicer:

vjianbolimsft_1-1662011320102.png

Then creata a measure:

Flag =
IF (
    MAX ( 'Table'[Winning Team] )
        IN SELECTCOLUMNS ( 'For Slicer', "Team", [Team] )
            && MAX ( 'Table'[Losing Team] ) IN SELECTCOLUMNS ( 'For Slicer', "Team", [Team] ),
    1,
    0
)

Add it to the filter:

vjianbolimsft_2-1662011554621.png

Final output:

vjianbolimsft_3-1662011639297.png

 

Best Regards,

Jianbo Li

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

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1662011263424.png

Please try:

First, create a new table of all the teams for slicer:

vjianbolimsft_1-1662011320102.png

Then creata a measure:

Flag =
IF (
    MAX ( 'Table'[Winning Team] )
        IN SELECTCOLUMNS ( 'For Slicer', "Team", [Team] )
            && MAX ( 'Table'[Losing Team] ) IN SELECTCOLUMNS ( 'For Slicer', "Team", [Team] ),
    1,
    0
)

Add it to the filter:

vjianbolimsft_2-1662011554621.png

Final output:

vjianbolimsft_3-1662011639297.png

 

Best Regards,

Jianbo Li

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

@Anonymous I would recommend 2 disconnected tables for your slicers. Both would be built using DISTINCT('Table'[teamname]). Then you could get the gameid's by doing something like:

Measure = 
  VAR __TeamA = SELECTEDVALUE('Slicer1'[teamname])
  VAR __TeamB = SELECTEDVALUE('Slicer2'[teamname])
  VAR __TeamAGames = DISTINCT(SELECTCOLUMNS(FILTER('Table',[teamname] = __TeamA),"__gameid",[gameid]))
  VAR __TeamBGames = DISTINCT(SELECTCOLUMNS(FILTER('Table',[teamname] = __TeamB),"__gameid",[gameid]))
  VAR __SharedGames = INTERSECT(__TeamAGames, __TeamBGames)
...

  

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  Thanks for your answer. 

I do kinda follow where you are going, however, I got no idea what to put into the return section of the measure, as I would like to display a table with all the gameid? - I do not see how I can filter the data tabel based on _SharedGames varaible?

poulsea_0-1660731027056.png

 

@Anonymous Yeah, I wasn't sure either! But, perhaps you could use this code in a Complex Selector. Essentially return 1 or 0 and use the Filter pane to filter to the 1's (the rows you want included in the visual). So like:

 

Measure = 
  VAR __Game = MAX('Table'[gameid])
  VAR __TeamA = SELECTEDVALUE('Slicer1'[teamname])
  VAR __TeamB = SELECTEDVALUE('Slicer2'[teamname])
  VAR __TeamAGames = DISTINCT(SELECTCOLUMNS(FILTER('Table',[teamname] = __TeamA),"__gameid",[gameid]))
  VAR __TeamBGames = DISTINCT(SELECTCOLUMNS(FILTER('Table',[teamname] = __TeamB),"__gameid",[gameid]))
  VAR __SharedGames = INTERSECT(__TeamAGames, __TeamBGames)
RETURN
  IF(__Game IN __SharedGames, 1, 0)

The Complex Selector - Microsoft Power BI Community

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.