Forum Discussion

ats1958's avatar
ats1958
Icon for Helper II rankHelper II
8 years ago

Getting Group/Attributes of a Filtered Item

I have a dataset of employees, which includes some additional information such as job title, department, and salary.

 

I want to allow users to select a given employee, then view visualizations for that employee's entire job title and department. For example, user selects Employee A, and then they view a scatter plot showing all the employee salaries in Employee A's department. Ideally, Employee A would be highlighted in this scatter plot

 

Any way to accomplish this within Power BI?

5 Replies

    • ats1958's avatar
      ats1958
      Icon for Helper II rankHelper II

      I don't think this is quite what I need.

       

      In the example, the dots in the scatter plot aren't changing, one is just being highlighted.

       

      What I'm looking to do is display a subset of the data in the chart.

       

      An example would be, if I have a list of cities, states, and populations, and a user selects "San Francisco," I'd want the chart to show all the cities in the California with their populations. And San Francisco would be highlighted in that chart.

      • OwenAuger's avatar
        OwenAuger
        Icon for Super User rankSuper User

        ats1958

         

        Here is a mock-up of what I think you are looking for.

        PBIX uploaded here

         

         

         

         

         

        This could be done a number of ways depending on your existing tables, and my mock-up could well be adapted/simplified.

         

        1. Add an Employee Filter table, containing a single column of Employee names, with an inactive relationship to your fact table.
        2. Create a measure Selected Employee Flag, which returns 1 if the currently visible Employees include those selected in the Employee Filter table (intended to be used only when filtering on individual Employees).
          Selected Employee Flag = 
          VAR EmployeesSelected =
              CALCULATETABLE (
                  VALUES ( Data[Employee] ),
                  USERELATIONSHIP ( Data[Employee], 'Employee Filter'[Employee Filter] ),
                  ALL ( Data )
              )
          RETURN
              IF (
                  NOT CALCULATE (
                      ISEMPTY ( VALUES ( Data[Employee] ) ),
                      KEEPFILTERS ( EmployeesSelected )
                  ),
                  1
              )
        3. Create another measure Selected Employee Department Flag which returns 1 if the currently visible Departments include those of the Employees selected in the Employee Filter table.
          Selected Employee Department Flag = 
          VAR DepartmentSelected =
              CALCULATETABLE (
                  VALUES ( Data[Department] ),
                  USERELATIONSHIP ( Data[Employee], 'Employee Filter'[Employee Filter] ),
                  ALL ( Data )
              )
          RETURN
              IF (
                  NOT CALCULATE (
                      ISEMPTY ( VALUES ( Data[Employee] ) ),
                      KEEPFILTERS ( DepartmentSelected )
                  ),
                  1
              )

        4. Create your visual (at an Employee level of detail), and add a Visual Level Filter "Selected Employee Department=1"
        5. Put the Selected Employee Flag in Color Saturation, and tweak colours as needed.
        6. If multiple Employees are selected, they will all be highlighted with relevant Departments shown.

        Regards,

        Owen