Welcome to MSDN Blogs Sign in | Join | Help

PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

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 …


(Click to enlarge)

… 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.


(Click to enlarge)

With two clicks, the conditional formatting is now applied to the cells I selected.


(Click to enlarge)

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).


(Click to enlarge)

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.


(Click to enlarge)

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


(Click to enlarge)

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.


(Click to enlarge)

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.


(Click to enlarge)

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.

Published Wednesday, December 21, 2005 9:57 PM by David Gainer

Comments

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Thursday, December 22, 2005 8:05 AM by Tommy
Compliments to the Excel-team. Apparently, you have given my favourite Excel-tool a terrific makeover. I have been sold on pivot tables right from the start, and as a local spreadsheet trainer I have always urged co-workers to explore this powerful feature. Still, I often find that people, while initially impressed, don't get around to using it in their day-to-day work. I think much of that will change with the enhanced functionality and the new, appealing UI.

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Thursday, December 22, 2005 9:51 AM by Tianwei
David, this is getting better and better. I do have one request to conditional formatting in general: visualization is great yet can be less meaningful once you have a lot of similar values (in your case mountain 48 and road 52 have similar values) it would be hard for eyes to tell. So here is my suggestion: provide another option that allow a floating rank (ascending or descending by user choice) of say, top 100 values. So mountain 48 will have a yellowish floating tag stating "#5", raod 52 has a tag stating "#4", or something like that. User would have some choices to rank up to 500, say, but can reduce ranking tags to top 10, top 5 etc.

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Thursday, December 22, 2005 11:53 AM by Roy
Love it!

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Thursday, December 22, 2005 1:47 PM by David Gainer
Thanks for the feedback, folks. Tianwei, thanks for the suggestion. You could use some of the conditional formatting rules we have added to do approximately what you are interested in, but we don't have one rule that does exactly that in v12.

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Thursday, December 22, 2005 2:06 PM by Murray
I like it. In the version I use (Excel 10), when the pivot table columns get rearranged (e.g. adding or removing fields), I have to manually readjust the column widths to accomodate the new data. Will Excel 12 do this for me automatically?

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Thursday, December 22, 2005 3:36 PM by Harlan Grove
Tommy...
...
|I have always urged co-workers to explore this
|powerful feature. Still, I often find that
|people, while initially impressed, don't get
|around to using it in their day-to-day work.
...

Depends on why one uses spreadsheets. The sine qua non of spreadsheets is automatic recalc. Pivot tables don't provide that, though the functionality could be implemented in VBA using the Calculate event handler to refresh pivot tables. However, if there are any GETPIVOTDATA calls, that approach could lead to circular recalc issues.

Pivot tables may be analytical tools, but they're more database tools than spreadsheet tools. Your co-workers may place higher importance on automatic recalc than ease of implementation or layout. If so, they'd be unlikely to change in Excel 12. But there'll always be people who (mis)use spreadsheets, including Excel, to produce reports, and Excel 12 may make it more attractive to do so.

# re: PivotTable VII: – Conditional formatting gets even better, or visualizing your data in PivotTables

Friday, December 23, 2005 10:46 PM by Jean Martineau
Great work.

# Office 12: ?????????? ?????????????? | ???????????????????? ??????????

New Comments to this post are disabled
 
Page view tracker