Conditional Formatting Controlled via Slicers!

 
Yes folks, we’ve seen all manner of parameterization by slicer.  We’ve even seen sort by slicer.  But now it’s time for me to track down a hunch I’ve had for awhile now:  we can also control conditional formatting via slicers!

image
At the 65th Percentile, Model Name Profits are Being Shaded Green

image

Getting Stricter:  Use the Slicer to Set the “Green Threshold” to 95th Percentile


Another Disconnected Table Technique

An old favorite.  First we just create a single column of numbers in Excel – the numbers that we want to appear on our slicer:

image

Copy a Single Column of Numbers Out of Excel

image

Paste as New Table in PowerPivot

 

image

Resulting CFMinBar Table

Then I write a measure on my new table:

image

Measure That “Harvests” the Selection from the Slicer –
Could Just Have Easily Used MIN() Rather than MAX()

Which then looks like this in a pivot:

image

Using Our New Slicer and Measure to Control Conditional Formatting

OK, let’s make a real pivot now – one with a useful measure on it:

image

Rather than display our [Selected Min CF Bar] on the pivot, I’m going to use a cube formula, off to the side, to capture that measure:

image

Cube Formula Used to Capture the [Selected Min CF Bar] measure value.  Note how it references the Slicer too, otherwise it would always return 95%.

Adding a Color Scale Rule

I’m just going to add a 3-Color Scale Rule to the pivot:

image

Adding the 3-Color Scale CF Rule

Then set it to affect the entire measure:

image

Resulting in:

image

Simple 3-Color Scale CF Rule

Now for the trick!

Here’s the sneaky part.  Go to Manage Rules:

image

Edit the one rule we have on the pivot, bringing up this dialog:

image

Note the Circled Buttons!  Those are Refedit Controls!
The Thresholds in the CF Rule Can Be Cell References!

OK, let’s set that to reference the cube formula cell I created previously:

image

Set it to Percentile and Reference the Cube Formula Cell

And then…

A Bug!

Or at least, I think it’s a bug.

Click OK and we get:

image

I really like the “was this information helpful?” link

Yes, I realize that it’s expecting an integer like 90 rather than a percentage value like 0.90 which is what my measure returns.  But I get this error message even when I just type the number 90 into a cell and then reference that cell. 

But it works if I just type 90 directly into the refedit control rather than a cell reference, it works.  Something is broken here.

I Still Got it Working by Using “Number”

I think it’s only the Percentile option that doesn’t like cell references.  The Number option works:

image

The Number Option DOES Work with Cell References

In order to use the Number option to let the user control percentile-based conditional formatting with a measure like [Profit], however, I need to get a bit more sophisticated with my measures.

I need to calculate, for instance, what the 90th-percentile [Profit] value is.

And that’s what I did.  But I’m out of time for today’s post.  So the full explanation must wait until Tuesday, sadly.

But in the meantime, you can experiment with the Number option as illustrated above, and have it reference a cube formula cell that returns a measure.  By Tuesday some of you may have more sophisticated examples than I do Smile

***UPDATE:  The second installment of this technique is now posted here.

2 Responses to Conditional Formatting Controlled via Slicers!

  1. Yes! Use this technique to dynamically set upper and lower limits for conditional formatting choices that are not color fields. Build two measures instead of one, and you have complete control over stoplight icons from a slicer or two. Next step – combine these measures with other variables in slicers to build visual what-if views (If I increased distribution to X% without exceeding 100%, which products would contribute the most incremental units? Now show them to me with highlighting!).

    PowerPivot is the ultimate playground, and Rob just keeps dumping toys on the field for all to use. Nice work!

  2. Natalia Garcia says:

    What about making diferrent conditional formating depending on what slicer combination you choose?
    For example if you have different targets for each fiscal year such as:
    -In 2005, at the 65th Percentile, model name profits are being shaded Green
    but
    -In 2004, at the 60th pecentile, model name profits have to be shaded green
    etc.

    Is it posible to do that?

Leave a Comment or Question