0

I have a slicer that filters a list based on names, the same table that the slicer references has a column for sport, i want to filter the names in a table based on the sport that corresponds the selected name on the slicer i.e if the name chosen plays a particular sport, i want the table to show the list of all the names that play the same sport as the selected name

I tried using this measure as a filter (I'm new to power Bi in case it looks crazy) and it didn't work: Measure = IF( HASONEVALUE('General info'[Name]), MAX( CALCULATETABLE( FILTER('General info', 'General info'[Sport] = SELECTEDVALUE('General info'[Sport])), ALL('General info'[Name]) ) ), BLANK() )

3
  • So each name in the table will only ever be associated with one sport, never multiple sports? Commented Apr 28, 2023 at 18:12
  • Yes each distinct name will always be only associated with one sport Commented Apr 28, 2023 at 20:44
  • You should format that code. Commented May 1, 2023 at 7:30

1 Answer 1

0

You'll have to create a separate table of names to use for the slicer, a table which is unrelated to your main table. For example, assuming you create a new table called Names which comprises a single column (called Name) of distinct names, you can then create the following measure:

=
VAR ChosenName =
    MIN ( Names[Name] )
VAR SportPlayedByChosenName =
    CALCULATE ( MIN ( 'Table'[Sport] ), 'Table'[Name] = ChosenName )
RETURN
    IF ( SUMX ( 'Table', 0 + ( 'Table'[Sport] = SportPlayedByChosenName ) ), 1, 0 )

You then add a slicer based on the Names table to the canvas, and create your chosen visual using the Name field from your main table, dragging the above measure into the filters pane for that visual, with the condition that it be equal to 1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.