A pivot table is a powerful tool that lets you group and summarize large amounts of data so you can draw meaningful insights. They let you use a wide variety of summarizing metrics to help you analyze data. Moreover, they come with a ‘Calculated field’ feature that enables you to customize the Pivot table results with special functions and formulae. Show
In this tutorial, we will show you step-by-step, with the help of a simple example, how to add a calculated field to a Google Sheets pivot table.
What is a Calculated Field?There are a number of analytical metrics that are built into a Pivot table, like sum, average, median, variance, etc. While these are quite helpful, they are usually not enough. We often need to perform other calculations that may not be present in the default Pivot table metrics. A calculated field becomes quite useful in such situations. Calculated fields help you use customized functions and formulae in a pivot table. They perform computations on data from your original table and display the results in the pivot table. How to Use Calculated Fields in a Google Sheets Pivot TableTo understand how calculated fields work, let us look at a simple example. Since this tutorial is primarily about calculated fields, we will not go over pivot tables in too much detail. We will simply create a basic pivot table and then move on to discussing how to add the calculated fields. If you would like to know more about pivot tables, you can read our in-depth article: How to Make a Google Sheet Pivot Table The following dataset contains 3 months’ sales data of employees from 3 different regions – East, West, and Central: To make this tutorial easier to understand, we used a fairly small and simple dataset. Pivot tables are usually used to analyze much larger datasets. We want to perform some analytics on the above data using Calculated fields in Pivot tables. There are an unlimited number of analytics that you can perform with calculated fields, but for this tutorial, let us assume that we want to create a pivot table to show the following:
To create a pivot table that can do this, we need to follow these steps:
Let’s go over each of these steps. Creating the Pivot TableThe first step is to create the pivot table. For this, follow the steps shown below:
You should also see the Pivot table editor as a sidebar on the right side of the window. This sidebar appears every time you click on a cell of the Pivot table. Since we want to display region-wise results, we can add unique regions from our dataset as separate rows of the pivot table. For this, follow the steps shown below:
Your pivot table is now ready for you to populate with your required calculated fields. Adding the Calculated Fields to the Pivot TableWe need to add a calculated field when the pivot table default / built-in functions do not include the computations we require. In our case, we need to combine and perform calculations on data from three different columns, a function that is not present in the default Pivot table functions. So we need to use a calculated field. To add a calculated field, follow the steps shown below:
At the moment, the calculated field simply shows a list of zeros in the pivot table, since we haven’t yet given it a formula. If you click on the dropdown under ‘Summarize by’ in the calculated field box (of the pivot table editor), you will notice you have two options:
Let us create two example calculated fields to understand the difference between these two options. Summarizing a Calculated Field by SUMWe want our first calculated field to display region-wise sales for the whole quarter. Notice that our original dataset contains sales made by each employee over 3 months – Apr, May, and June. But we want to consolidate the three month’s sales to get the total sales for the whole quarter. Moreover, we want this result to be summed up region-wise. In other words, we want the results summarized by sum (for each region). So let us configure the first calculated field as follows:
That’s it! Your calculated field should now show region-wise total sales in all 3 months – Apr, May, and June. You can change the name of the calculated field column by double-clicking on it and typing in the new name, as shown below: Summarizing by Custom FormulaNext, we want to add 3 calculated fields to display the region-wise count of employees who made more than $50,000, one for each month. Since we want to count based on a condition, we will need to use the COUNTIF function, which is not present in the list of default pivot table functions. Note that we want to count each sales value individually (we don’t want to sum up the counts). In other words, we don’t want the results summarized by SUM. Add a new calculated field for the month of April and configure it as follows:
This will display the region-wise total count of employees who made sales of more than $50,000 in April. Change the name of the calculated field column at this point. Repeat the same for May and June. Here’s how our Pivot table looks in the end: Important NotesCalculated fields can provide added functionality to your pivot tables. However, there are a few things that should be kept in mind when using them:
Calculated Field FAQsHow do I add a calculated field in Google Sheets?You can add a calculated field to your Pivot table by following the steps below:
What is a calculated field in Google Sheets?A calculated field in a Google Sheets Pivot table is one that contains a special formula that refers to other fields of the original dataset. We usually use calculated fields when the built-in summary functions available with the pivot tables don’t include the computation that we need to perform. With calculated fields, you can create your own formulas and apply them to your pivot table. How do you insert a formula in a Google Sheets calculated field?After adding the calculated field, you should see a description box for it in the Pivot table editor. In this box, simply enter your formula in the input box under ‘Formula’. Make sure it uses the correct field names. If there are spaces in the field name, then make sure you enclose it in single quotes. ConclusionIn this tutorial, we discussed Calculated fields in Google Sheets pivot tables. We explained when to use them and how to add them to a pivot table. We also showed you two examples of calculated fields – one which displays data summarized individually and another which summarizes by SUM. We hope we have given you a basic idea and guideline on adding calculated fields to your pivot tables. Can you calculate percentage in pivot table?To calculate % of Sales for each month, you need to do the following: Click on pivot builder the entry Sum of Sales and select Value Field Settings. In the Value Field Settings window, on the Show Values As tab, choose % of Column Total. Click OK.
How do I add a calculated field to a pivot table in Google Sheets?Calculated fields with SUM or a custom formula. On your computer, open a spreadsheet in Google Sheets.. Click the pop-up Edit button underneath the pivot table.. In the side panel, next to "Values," click Add. click Calculated field. ... . On the bottom right, click Add and the new column will appear.. How do I add %age to a pivot table?Group by age in pivot table. Create a pivot table, and then add the Age as a Row Label, and the Option as a Column Label, finally, add Name as Value, and you will get the pivot table as below screenshot:. Right-click any cell in the Age field and choose Group from the context menu, see screenshot:. How do you automatically calculate percentages in Google Sheets?How to Calculate Percentage of a Proportion. Select cell D2 (where the first row's result will be displayed).. Type the formula =C2/B2.. Press the 'Format as percent' button (%) from the toolbar. ... . You should see the result in the second row of column D.. How do I show both values and percentage in a PivotTable?Follow these steps, to show the percentage of sales for each item, within each Region column.. Right-click one of the Units value cells, and click Show Values As.. Click % of Column Total.. The field changes, to show the percentage of sales for each item, within each Region column.. |