Forum Discussion
Request for help creating a filter on a Matrix Table
- 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.
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.
what do you think of this modification (to the conditional statement in your RETURN) to help this work when a person is not at a location, so when there is no time value for that location and perosn combination, when "SelectedPersonTime" is blank, and to fiter those records out:
AND( NOT ISBLANK(SelectedPersonTime) , MAX('Data'[Time]) >= SelectedPersonTime ), -- Show rows with time >= selected person's time