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!

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

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:

Copy a Single Column of Numbers Out of Excel

Paste as New Table in PowerPivot

Resulting CFMinBar Table

Then I write a measure on my new table:

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:

### 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:

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:

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:

Adding the 3-Color Scale CF Rule

Then set it to affect the entire measure:

Resulting in:

Simple 3-Color Scale CF Rule

### Now for the trick!

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

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

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:

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:

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:

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

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

0 Shares