How to Add Calculated Field to Pivot Table in Google Sheets
In Google Sheets, you can't add a calculated field directly to a pivot table, but you can create a new column in the source data and include it in the pivot table. Here's how you can do it:
- Open the Google Sheets document containing the source data for your pivot table.
- Add a new column to your source data by clicking on the lettered header of the column to the right of where you want the new column to appear, then right-click and select "Insert 1 left" or "Insert 1 right" as needed.
- In the new column, add a header in the first row to describe the data (e.g., "Calculated Field").
- In the second row of the new column, enter the formula or calculation you want to apply to the data, using cell references from the same row. For example, if you want to calculate the percentage from columns B and C in the same row, you would enter "=B2/C2" (without quotes).
- Press Enter, and the formula will be applied to the cell.
- Click on the bottom-right corner of the cell containing the formula, and drag it down to fill the entire column with the same formula applied to each row.
- Now, go to the sheet containing the pivot table.
- Click on any cell in the pivot table to show the "Pivot table editor" panel on the right side of the screen.
- In the "Pivot table editor" panel, under the "Rows," "Columns," or "Values" section (depending on where you want to add the calculated field), click on "Add" and select the header of the new column you created in the source data.
- The calculated field will now be added to the pivot table.
Example
Let's say you have a dataset with the following columns: Product, Sales, and Expenses. You want to add a calculated field to your pivot table that shows the Profit Margin, which is calculated by dividing Profit (Sales - Expenses) by Sales.
- Add a new column to your source data with the header "Profit Margin."
- In the second row of the new column, enter the formula "=(B2-C2)/B2" (without quotes), assuming Sales are in column B and Expenses are in column C.
- Copy the formula down the entire column.
- Go to the sheet containing the pivot table and open the "Pivot table editor" panel.
- In the "Pivot table editor" panel, under the "Rows," "Columns," or "Values" section (depending on where you want to add the calculated field), click on "Add" and select "Profit Margin."
- The Profit Margin will now be included in the pivot table.
Did you find this useful?