Forum Discussion
Automatic Filtering for Slicers
HI SHA03 ,
You can achieve this using SELECTEDVALUE and LOOKUPVALUE in DAX to dynamically filter the department and level based on the selected employee.
Solution Approach
Create Measures for Department & Level Selection
Use the SELECTEDVALUE function to get the department and level of the selected employee.
Use LOOKUPVALUE to extract the department and level from the employee table.
Apply These Measures as Filters
Modify your existing visuals for "Same Department" and "Same Level" employees using these measures as filters.
Step-by-Step Implementation
1. Create a Measure for the Department of the Selected Employee
Selected_Dept =
VAR _SelectedEmp = SELECTEDVALUE(EmployeeTable[Employee Number])
RETURN LOOKUPVALUE(EmployeeTable[Department], EmployeeTable[Employee Number], _SelectedEmp)
2. Create a Measure for the Level of the Selected Employee
Selected_Level =
VAR _SelectedEmp = SELECTEDVALUE(EmployeeTable[Employee Number])
RETURN LOOKUPVALUE(EmployeeTable[Level], EmployeeTable[Employee Number], _SelectedEmp)
3. Apply These Measures as Visual-Level Filters
In the visuals showing employees from the same department, set a visual-level filter where:
EmployeeTable[Department] = [Selected_Dept]
In the visuals showing employees from the same level, set a visual-level filter where:
EmployeeTable[Level] = [Selected_Level]
Expected Outcome
When a user selects an employee, the department and level slicers are no longer needed.
The "Same Department" and "Same Level" visuals will automatically filter based on the employee’s department and level.
Please mark this post as solution if it helps you. Appreciate Kudos.
Hello Farhan,
Appreciate your reply however your solution doesn't work. When using SelectedValue as a visual level measure it wouldnt show any data, as there's no interaction between the employee number slicer and the visuals so the SelectedValue based on employee number naturally wont appear.
I also tried keeping the interaction between the main slicer and visuals but that didnt work as well.
besides this, i've already tried creating a calculated column (and a calculated table) to use in the measures instead of the main 'employee number' column but this solution didnt work either.
Let me know if you have any other ideas!