Forum Discussion

joemako's avatar
joemako
New Member
1 year ago
Solved

Request for help creating a filter on a Matrix Table

I am fairly new to Power BI and Dax, and I am trying to add a filter on a Matrix Table object on a page.   here is my example dataset: Location Time Person a 1 joe a 2 sam a 3 ...
  • marcelsmaglhaes's avatar
    1 year ago

    Hey joemako ,

    To achieve that, we will use a disconnected table for the slicer to avoid direct filtering of rows.


    Steps:
    1. Create a Disconnected Table for the Slicer:
    Create a new table to use as a slicer, which contains the distinct persons but is not linked to the main data table.

    SlicerPersonTable = DISTINCT(SELECTCOLUMNS('Table', "Person", 'Table'[Person]))


    2. Add the Slicer for Person:
    Use the SlicerPersonTable[Person] column in a slicer to allow users to select the person.


    3. Create the Filtering Measure:
    Now, create a measure that will allow filtering based on the selected person’s time but keep all other rows for the same location:


    FilteredRows =
    VAR SelectedPerson = SELECTEDVALUE('SlicerPersonTable'[Person]) -- Get the selected person from the slicer
    VAR SelectedPersonTime =
        CALCULATE(
            MAX('Table'[Time]), -- Get the time of the selected person at the location
            ALLEXCEPT('Table', 'Table'[Location]),
            'Table'[Person] = SelectedPerson
        )
    RETURN
    IF(
        MAX('Table'[Time]) >= SelectedPersonTime, -- Show rows with time >= selected person's time
        1,
        0
    )


    4. Apply the Measure as a Filter:

    Go to your Matrix visual.
    In the Filters on this visual pane, drag the FilteredRows measure and set it to show only values where FilteredRows = 1.