One Slicer to Control Them All…

 

One Slicer That "Controls" Other Slicers.  Multiple slicers "get set" when the user makes one click.

Got this question yesterday from the DJ Monkey…

Let’s say you have three slicers:  Percentile, Quarter, and Category:

image

For Bikes, You Always Want to See the 70th Pctile in Q2

And you find yourself selecting the same combinations over and over again.  Above, you selected 70, 2, and Bikes – because Quarter 2 is essential for Bike sales, and 70 is the percentile you are most interested in for bikes.  (Note that this percentile drives conditional formatting in this example – see this post for details).

When you look at Accessories, you always want to see Q1 instead, and set the Percentile threshold to 60.  And for Clothing, it’s a different set as well:

image

But for Accessories, You Always Want to See the 60th Pctile in Q1

image

And for Clothing, It’s 80 and Q4 That You Always Want to See

Is that too repetitive for you?  Three clicks with a brief pause in between each makes you feel like a monkey?  There’s no satisfying you, is there? Sheesh Smile

But hey, there’s a way to essentially set multiple slicers in one click, without VBA, as long as you know ahead of time what the desired combinations are.


Yet Another Disconnected Slicers Trick

First I create a new table, which I have named MasterSlicer:

image

Behold, the MasterSlicer Table!  OK yeah it doesn’t look like much.

And for temporary illustration purposes, I’ll create a new pivot and put the Label column on a slicer:

image

Label Column from MasterSlicer, Used as a Slicer

And then I write three “harvester” measures that detect what the user has selected on the Master Slicer:

[Selected Category] =
MAX(MasterSlicer[Category])

[Selected FiscalQtr] =
MAX(MasterSlicer[FiscalQtr])

[Selected Pctile] =
MAX(MasterSlicer[Pct])

So when I select “Bikes 70 Q2” on the slicer, I get the following in the pivot:

image

The Harvester Measures Just Return the Contents of the Selected Row in MasterSlicer

So far so good.

Step 2:  A Profit Measure That Respects MasterSlicer

Returning to the original pivot, My [Profit] measure needs to be modified now.  (I could also create a new measure, and I probably would, but for now let’s just modify the one I have).

[Profit] =
CALCULATE( SUM(Sales[Margin]),
           FILTER(Products, Products[CategoryID]=
                           
[Selected Category]
                 ),
           FILTER(Calendar, Calendar[FiscalQuarter]=
                            [Selected FiscalQtr]
                 ),
           FILTER(CFMinBar, CFMinBar[Pct]=[Selected Pctile])
          )

Results

Ok, now you have a single slicer that does the work of three:

One Slicer That "Controls" Other Slicers.  Multiple slicers "get set" when the user makes one click.

Important Notes

1) First, I really messed up by using the Conditional Formatting slicer as one of the three slicers in this example.  It needlessly complicated an otherwise simple concept.  Go read that original post if you’re interested, but I’m going to leave it out of this post from here on.

2) You CANNOT Use this technique in conjunction with the normal slicers.  It is one or the other.  Even when there is no selection made on the MasterSlicer, the MAX() logic in the harvester measures kicks in and picks 80, 4, and 3, and then the FILTER()’d version of [Profit] respects that.

So you either go back to using the normal [Profit] measure and the normal slicers, or this disconnected MasterSlicer and the FILTER()’d version of [Profit] – this is why I would normally create a new version of the [Profit] measure rather than modifying the one I have.

Visualizing this Technique

image

I use this illustration technique a lot in the book.  Filter/Lookup/Dimension tables displayed above the Data/Fact tables, with orange arrows indicating the direction that filters flow.

Dotted lines indicate “artififical” or “virtual” relationships – relationship-like behaviors that are expressed in measure formulas (using FILTER).

So the user’s selections on MasterSlicer flow through to Products and Calendar via FILTER() measure logic, and then those filters flow through to Sales (where [Profit] is) via normal relationships.

What About Text Columns?

Originally, I did not have a [CategoryID] in my Products table, I just had the [Category] column, which was text.  And for my harvester measure, numerical functions like MAX() don’t work with text.

In this case I used a SWITCH() to add a calculated column:

image

In cases where you have too many text values to write a reasonable SWITCH(), I suppose you could use text measures with VALUES() and skip the creation of this column, but that’s a topic for another day.

2 Responses to One Slicer to Control Them All…

  1. Ted Murphy says:

    Hi Rob,

    I have a text column on a disconnected table that I want to use as a slicer. There are too many values to use Switch as described above (and the text values are subject to change by the user) … I cannot use Max() to determine the value selected in the slicer. Did you ever get to write a blog on using the Values() function?

    Hope this does not get in the way of Thanksgiving!

    Regards,

    Ted Murphy

    • Ted Murphy says:

      Hi Rob,

      Please disregard the above comment re text column. I revisited the Disconnected Slicer Techniques in the Advanced PowerPivot Lessons and got a solution.

      Thanks,

      Ted.

Leave a Reply