Home > Pivot Tables > Pivot Fields Excel Pivot Table Field SettingsHow to use Pivot Table field settings, to show or hide pivot table subtotals, show items with no data, show top items and sort fields, in Microsoft Excel |
Pivot Field Settings - IntroductionWhen you right-click a pivot table cell, a pop-up menu appears. This menu is contextual - it shows commands that apply to the type of cell that you right-clicked.
In most of the pop-up menus, you'll see one of these two different field setting commands, depending on the cell type:
1) Field SettingsThe examples on this page show how to make changes to pivot fields in the Row, Column and Filter areas. When you right-click a cell in one of those areas, The Fields Settings command is in the pop-up menu, near the bottom of the list. Click that command, to open the Field Settings dialog box. The examples on this page show how to use the settings on the two tabs:
Field Settings on Excel RibbonInstead of using the right-click pop-up menu, you can open the Field Settings dialog box by using a command on the Excel Ribbon. To use the Ribbon command, follow these steps:
|
2) Value Field SettingsIf you right-click a cell in the Values area of a pivot table, the pop-up menu has a Value Field Settings command, instead of a Field Settings command.
In the Value Field Settings dialog box, you can do the following:
Follow those links, to learn more about the Value Field Settings. |
Quickly Remove a Pivot FieldAfter you create a pivot table, you might want to remove a field from the layout. You don't need to go to the field list, find that field and remove its check mark, or drag the pivot field out of the Row Labels area in the field list. NOTE: You can also use macros to remove pivot fields -- Remove Pivot Fields with Macros To quickly remove a pivot field from the layout:
The pivot field is immediately removed from the layout To see the steps for quickly removing a pivot field, you can watch this short video tutorial. |
Add All Remaining Fields to LayoutIn the Pivot Table Field List, you can check a field name to add it to the pivot table layout. You have to do these one at a time though -- there isn't a "Select All" checkbox. With the following code, you can add all the unchecked fields to either the Row Labels area or to the Values area of the layout. Put this code in a regular code module. Then select a cell in the pivot table that you want to update, and run the macro. Add All Remaining Fields to Row LabelsIf you have a long list of fields, you could manually add a few to the Values area, or the Report Filter area. Then use the following code to add the remaining fields to the Row Labels area. Sub AddAllFieldsRow() Dim pt As PivotTable Dim iCol As Long Dim iColEnd As Long Set pt = ActiveSheet.PivotTables(1) With pt iCol = 1 iColEnd = .PivotFields.Count For iCol = 1 To iColEnd With .PivotFields(iCol) If .Orientation = 0 Then .Orientation = xlRowField End If End With Next iCol End With End Sub |
Missing Data in Pivot TableTo see items with no data in a pivot table, you can change the pivot table settings, as described in the section above. However, that setting only displays items that are included in the source data at least once. For example, if you recently started selling a new product, but have no sales yet, it won't appear in your pivot table, even if you turn on the "Show Items With No Data" setting. Show Missing DataTo show missing data, such as new products, you can add one or more dummy records to the pivot table, to force the items to appear. For example, to include a new product -- Paper -- in the pivot table, even if it has not yet been sold:
Count Missing Data as ZeroIn addition to simply showing the names of missing data, you might need to show a count of that data in the pivot table report. Get the sample file for this example in the download section below. Thanks to AlexJ for sharing his solution to this problem. On my Contextures blog, there is a Health and Safety example, which creates a quarterly report on safely incidents. Two of the six departments did not have incidents, and are not listed in the data. However, we'd like the report to show a count of zero incidents for those departments, instead of omitting them. Here is the pivot table with the four departments that had incident counts. To include the missing departments, add dummy records to the source data, and add an "X" in the numeric field that will be counted (ID field in this example). If the field used the default Count function, it will show a 1 for the missing departments, because it is counting text entries, as well as numeric entries. Instead, use the Count Numbers summary function, to show those values as Zeros. To change that setting, right-click one of the numbers, and click Summarize Values By, then click More Options. In the list of functions, select Count Numbers. With that function selected, the pivot table shows the missing departments, with zeros as the count of incidents. |
Show Top Items OnlyUse the Top 10 filter feature in an Excel pivot table, to see the Top or Bottom Items, or find items that make up a specific Percent or items that total a set Sum. There are written steps on the Pivot Table Top 10 Filters page. Include New Items in Manual FilterIf you click on the arrow in a pivot table heading, you can filter the field's items, by using the check boxes. In the screen shot below, only two of the technician names have been selected, and the others will be hidden. However, if you add new records in the source data, or update the existing records, new names might be added to the source data. Then, if you refresh the pivot table, those new names can appear in the filtered pivot table, even though they were not originally selected. Here, Smith appears in the pivot table, after that name was added to the source data. To prevent new items from appearing after a manual filter has been applied, you can change a setting for the pivot field:
NOTE: If any new items were included before you change the setting, go back to the manual filter and remove the check marks for those items.
To see the steps for changing the pivot field setting, please watch this short video tutorial. |
Insert Blank LinesTo make a complex pivot table easier to read, add a blank line after each item in the main row fields. In the screen shot below, the outer field is "Category", and I'd like a blank row after the Revenue Total.
However, don't do this for every field, or the pivot table will be too spread out -- use this "blank line" setting on one or two of the outer fields. NOTE: You can also use PivotTable Styles to make the data easier to read. There are many built-in styles, or create custom styles, using your own colour and formatting preferences. Sort All Fields in Ascending OrderAfter adding new records to your data, new items may appear at the end of the existing data, instead of being listed alphabetically. The following code will sort all fields in all Excel Pivot Tables. Sub SortAllFields() 'pivot table tutorial by contextures.com On Error Resume Next Application.ScreenUpdating = False Dim pt As PivotTable Dim ws As Worksheet Dim pf As PivotField For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.ManualUpdate = True For Each pf In pt.PivotFields pf.AutoSort xlAscending, pf.Name Next pf pt.ManualUpdate = False Next pt Next ws Application.ScreenUpdating = True End Sub |
Get the Sample WorkbooksMissing Data: Download the sample file with health and safety data, and add dummy records, to show missing data with a count of zero. The zipped file is in xlsx format, and does not contain any macros. Pivot Field Macros: To see the code, and test the macros, download the Pivot Table Field Settings file. The zipped file is in xlsm format, and contains macros. Be sure to enable macros when you open the file, if you want to test the code. |
More Pivot Table Resources |
Last updated: August 31, 2022 3:02 PM