In a series of previous articles I introduced the new conditional formatting capabilities in Excel 12 (see here for the whole series of posts). Today I want to add one more article to the series, which is the work we have done to make conditional formatting work really well in Excel PivotTables. This is an area that I love to show people, because the work we have done reduces a formerly-tricky task down to a few clicks.
The first point I want to make is that all the features we added around new types of conditional formatting (data bars, colour scales, icon sets, etc.), new rules (top 10, below average, etc.), and new UI are available for use on PivotTables. However, we did not stop there. To provide a great experience with conditional formatting inside PivotTables, we now associate the conditional formatting rules to the structure of the PivotTable instead of to the cells. What this means is that as users work with PivotTables (adding and removing fields, refreshing the data, expanding and collapsing levels, Pivoting fields between rows and columns, grouping fields, etc.), the formatting tracks the cells in the PivotTable appropriately, so the users donâ€™t need to worry about what is happening to the formatting â€“ things just work, and they can focus on analyzing their data instead. Letâ€™s walk through an example.
In the PivotTable below Iâ€™m looking at sales for different bike models, and I have arranged my report so that I have a column with sales data for each year. To make it easier to visually compare the sales of various bike models, I want to apply conditional formatting to the sales values. In the same way as I would when conditionally formatting â€œordinaryâ€ (i.e. non-PivotTable cells), I select some cells containing sales values â€¦
â€¦ and then I use the ribbon to add a Data Bar format which helps users quickly scan their data to compare values and find outliers.
With two clicks, the conditional formatting is now applied to the cells I selected.
This is helpful, since I can now easily get a much better sense as to the relative sizes of the numbers I have selected, but oftentimes what I actually want is to apply the conditional formatting to *all* cells displaying bike sales. In this example, I might want to compare mountain bikes with road bikes using the same conditional formatting rule, but I want to avoid formatting subtotals (such as the total for the entire Mountain Bike category), since they would skew the results. You might be thinking â€œthatâ€™s going to take a lot of multiple-selection, especially on big PivotTables with a lot of levels.â€ To make it very easy to choose the â€œscopeâ€ of a conditional formatting rule in a PivotTable, Excel 12 provides some â€œon-object-UIâ€ (OOUI) which gives you the choice of which scope you meant for the rule to be applied to (by scope I mean which set of cells get the conditional formatting).
Let me briefly explain the three options. (Note, we are still working on the wording of the last option. Itâ€™s also worth noting that these options are also exposed in the conditional formatting creation and management UI, so you donâ€™t have to rely on the on-object UI.)
- Selected cells â€“ this will leave the conditional formatting applied to just the selected cells
- All â€œSum of Sales Amountâ€ cells â€“ this will apply the conditional formatting to all Sum of Sales Amount cells in the PivotTable, regardless of level, and including subtotals. This will be useful in cases for measures that arenâ€™t sums â€“ if you have an â€œAverage Retentionâ€ measure, for instance, all values (including subtotals and grandtotals) will be between 0 and 1 and can be sensibly formatted using a single rule.
- All â€œSum of Sales Amountâ€ cells with the same fields â€“ this will apply conditional formatting to all Sum of Sales Amount cells at this level in the PivotTable, which excludes subtotals. I suspect this will be the most commonly used.
In this case, I want to apply the rule to all cells displaying sales for individual bike models and individual years. To do this, Iâ€™ll pick: All â€œSum of Sales Amountâ€ cells with the same fields. After I have made this selection, the PivotTable will now show the conditional formatting in all cells showing sales for an individual product category and an individual year.
Youâ€™ll notice that there is no conditional formatting of the sales values for the â€œProduct Categoryâ€ field (â€œMountain Bikesâ€ and â€œRoad Bikesâ€). It wouldnâ€™t make much sense since those values are not at the same level as the values for the individual products.
For the sake of completeness, here is what the PivotTable would look like if I had selected All â€œSum of Sales Amountâ€ cells
However, this doesnâ€™t make much sense in this particular example because the grand totals skew the formatting in all the other cells so itâ€™s hard to spot any differences. That said, this type of scoping works great for relative values, (for example % profitability) where you can directly compare values at any level of detail.
Once the conditional formatting is applied, I can interact with the PivotTable and the formatting will be reevaluated dynamically (as I mentioned above). For example, if I change my report filter to only show sales to a specific country, the sales values will be reduced to only show that information and the conditional formatting will be automatically reevaluated to reflect the new values.
I can also add and remove fields and have the formatting adjust to that. Here is a screenshot of the same PivotTable after having removed the â€œProduct Categoryâ€ field.
And if I add another field instead, the conditional formatting rule is automatically reevaluated again. Here is a screenshot of the PivotTable after adding the â€œCountryâ€ instead of the â€œProduct Categoryâ€ field I removed before.
Thatâ€™s the summary for conditional formatting and PivotTables. With these improvements, PivotTables can now be used as a great tool for exploring data, highlighting trends, spotting outliers, etc.