Forum Discussion

RobbLewz's avatar
RobbLewz
Helper II
5 years ago
Solved

Filter chart by selected user's group

I have an individual employee report page I am putting together.

 

The majority of the information on the page will be for the choosen employee.  However, I have a bar chart that I want to show everyone in the same group as the selected employee but having trouble achieveing this.

 

I have a single select slicer where you can choose an employee by name.  The slicer is configured to filter most things on the page but the column chart is set to ignore the slicer, so when I choose an employee it displays all employees in their group.

 

table strucure is roughly like so

 

DimEmployee

IdNameGroup
1MaryGroup A
2PaulGroup A
3LisaGroup B
4FredGroup B

 

FactTotals

EmployeeIdTotal
11000
23000
etcetc 

 

So if I selected "Mary" from the slicer, the chart should show Mary & Paul as the axis and their SUM(total) as the values.

 

I can't use SELECTEDVALUE(DimEmployee[Name]) as Measure on the chart because it isn't being filtered by the filter so evalutes on a row basis.

 

Is there a way to lookup the SELECTEDVALUE() of a specific slicer or store it as a global parameter? 

 

I also tried creating a hidden slicer.  The slicer just showed the groups, and was filtered by employee slicer.  The problem is though, if you select Mary, this group slicer would highlight Group A but when you changed Selection to lisa, it adds group b to the list but keeps group A highlighted, so useless really.

 

 

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi RobbLewz ,

     

    According to my understand, you want to display all other users in the same group as the selected user, right?

     

    Please follow these steps:

    1. Create a new table with Name columns for slicer like this:

    2. Build relationships based on IDs.

    3. Create a measure using the following formula and apply it to filter pane:

    Measure =
    VAR _group =
        CALCULATE (
            MAX ( 'DimEmployee'[Group] ),
            FILTER (
                ALL ( 'DimEmployee' ),
                'DimEmployee'[Name] = SELECTEDVALUE ( ForSlicer[Name] )
            )
        )
    RETURN
        IF ( MAX ( 'DimEmployee'[Group] ) = _group, 1, 0 )

     

    Here is the pbix file.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    Best Regards,
    Eyelyn Qin

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi RobbLewz ,

     

    According to my understand, you want to display all other users in the same group as the selected user, right?

     

    Please follow these steps:

    1. Create a new table with Name columns for slicer like this:

    2. Build relationships based on IDs.

    3. Create a measure using the following formula and apply it to filter pane:

    Measure =
    VAR _group =
        CALCULATE (
            MAX ( 'DimEmployee'[Group] ),
            FILTER (
                ALL ( 'DimEmployee' ),
                'DimEmployee'[Name] = SELECTEDVALUE ( ForSlicer[Name] )
            )
        )
    RETURN
        IF ( MAX ( 'DimEmployee'[Group] ) = _group, 1, 0 )

     

    Here is the pbix file.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    Best Regards,
    Eyelyn Qin

    • RobbLewz's avatar
      RobbLewz
      Helper II

      Thanks for the reply.

      Your method sounds like it will work, I found a very similar way in the end.  I duplicated the employee table (which also has the group id in it) for the slicer.  I joined the duplicated employee table to the "normal" employee table using a distinct list of group Id's as a bridging table.

      If you use the "normal" employee table to provide the employee name as the chart axis then there is no need for a filter as that comes from the bridging table between the normal and duplicate table.

       

      It's shocking sometimes how over complicatied everyting must be in power BI to achieve such simple things.