Search code examples
powerbidaxvisualizationdata-analysispowerbi-desktop

Hiding/obfuscating all but one legend on the x-axis


Let's say I have a table listing employee names, certain performance aspects and scores, something like:

 Name | Measure | Score
 Alice| A       | 10
 Alice| B       | 5
 Alice| C       | 7
 Bob  | A       | 8
 Bob  | B       | 5
 Bob  | C       | 4
 Carol| A       | 6
 Carol| B       | 8
 Carol| C       | 7

This data is presented in a simple stacked column chart:

enter image description here

What I would like to do, is to find a way to hide all but one the x-axis legends (Name - Alice, Bob, Carol) depending on which name is selected from the slicer above.

So say Alice is selected, only her name would be displayed, the other columns would still be there but without their corresponding names, something like:

enter image description here

Selecting Bob would hide the other two names etc.

Any help would be appreciated


Solution

  • Here you go.

    enter image description here

    You need to create 3 additional columns as follows.

    enter image description here

    My code for these is:

    Alice = 
     SWITCH(TRUE(), 
     'Table'[Name] = "Alice", "Alice",
     'Table'[Name] = "Bob", UNICHAR(8203),
     'Table'[Name] = "Carol", REPT( UNICHAR(8203), 2), 
     BLANK()
     )
    
    Bob = 
     SWITCH(TRUE(), 
     'Table'[Name] = "Alice", UNICHAR(8203),
     'Table'[Name] = "Bob", "Bob",
     'Table'[Name] = "Carol", REPT( UNICHAR(8203), 2), 
     BLANK()
     )
    
    Carol = 
     SWITCH(TRUE(), 
     'Table'[Name] = "Alice", REPT( UNICHAR(8203), 2),
     'Table'[Name] = "Bob", UNICHAR(8203),
     'Table'[Name] = "Carol", "Carol", 
     BLANK()
     )
    

    Insert a new field parameter as follows.

    enter image description here

    Create your chart as follows.

    enter image description here