Excel · ChatGPT

How to Create a Pivot Table in Excel with ChatGPT

Describe your data, Excel version, PivotTable source type, and reporting goal. ChatGPT can then propose a field layout, grouping steps, calculated-field or measure approach, and validation checks that you can apply and verify in Excel.

Choose your situation — copy the prompt:
I need to build a PivotTable report in Excel.

EXCEL VERSION:
[Microsoft 365 / Excel 2024 / 2021 / 2019 / 2016]

PIVOTTABLE SOURCE TYPE:
[worksheet table/range / Data Model / external OLAP source / not sure]

MY DATA (paste 5–10 rows including headers):
[Paste your header row and sample rows here]

REPORTING GOAL:
[e.g. "Revenue by Region and Product Category, with gross
margin %, filtered to current year"]

CALCULATED FIELDS NEEDED (if any):
[e.g. "Gross Margin % = (Revenue − COGS) / Revenue"
 — leave blank if none]

DATE GROUPING (if your data has a date column):
[e.g. "Group dates by Month and Quarter"
 — or "No date grouping needed"]

FILTER REQUIREMENTS:
[e.g. "Filter by Year, current year selected by default"
 — or "No filters needed"]

Rules:
- Use only the column names from my actual data.
  Do not invent columns that are not present.
- If a calculated field requires a column that does not exist,
  say so explicitly — do not assume.
- Specify field placement exactly: Rows / Columns / Values / Filters.
- For each Values field, specify: summarisation type (Sum/Count/Average)
  and number format (Currency, Percentage 1dp, etc.).
- For date grouping: give exact steps (right-click → Group → level).
- If I ask for a calculated metric, first decide whether I need:
  a classic PivotTable Calculated Field, a source helper column, or a
  Data Model/Power Pivot measure.
- Do not give Calculated Field menu steps if my PivotTable source does not
  support classic calculated fields.
- For ratios, explain whether the required business result is a ratio of
  aggregated totals or an aggregation of row-level ratios.

Output:
1. Pivot layout specification (Rows / Columns / Values / Filters)
2. Step-by-step Excel setup instructions
3. Calculated field / helper-column / measure recommendation, with formula if applicable
4. Recommended sort order and number format for each Values field
5. Date-grouping and slicer instructions, if supported
6. At least one control calculation I can use to verify the PivotTable result

Paste your real column headers and sample rows — ChatGPT uses your actual column names in the instructions. Works in ChatGPT.

I need to add a calculated metric to an existing PivotTable in Excel.

Excel version:
[Microsoft 365 / Excel 2024 / 2021 / 2019 / 2016]

PivotTable source:
[worksheet table/range / Data Model / external OLAP / not sure]

Underlying source fields available:
[e.g. Revenue, COGS, Order ID]

Current Values area:
[e.g. Sum of Revenue, Sum of COGS, Count of Orders]

The metric I want to add:
[e.g. "Gross Margin % = (Revenue − COGS) / Revenue"]

Please tell me first whether this PivotTable supports a classic Calculated Field.

Then tell me:
- Whether the business metric should be calculated from aggregated field totals
  or from row-level values
- Whether a classic Calculated Field gives the correct subtotal/grand-total behavior
- The exact formula and menu path if a classic Calculated Field is appropriate
- Otherwise, whether I should use a source helper column or a Data Model/Power Pivot measure
- One numeric test I can use to verify the Grand Total

Calculated field syntax is different from regular Excel formulas — ChatGPT writes it correctly for the dialog.

My pivot table has a problem. Please diagnose it.

Problem: [describe what you see — e.g. "(blank) rows appearing",
"can't group dates by month", "grand total is wrong",
"calculated field shows wrong %"]

Excel version: [version]
PivotTable source: [worksheet table/range / Data Model / external source / not sure]
My source data columns: [list them]
The field causing the issue: [e.g. "Date column", "Category column"]
Sample of the raw data for that column: [paste a few values]
What I already tried: [refresh / regroup / changed source / nothing]

Please:
1. List the plausible causes supported by the evidence I provided
2. Tell me what to check first before changing data
3. Give the exact fix only after stating the assumption it depends on
4. Tell me whether I must refresh the PivotTable or change its source
5. Give me a verification check so I can confirm the fix worked

Useful evidence to include: real date values vs text, blank cells, trailing spaces/aliases, subtotal rows, source type, and whether Refresh changes the result.

Before — flat transaction table, no pivot layout yet
ExcelHomeInsertDataPivotTable
E2
fx
8400
ABCDEF
1RegionRepCategoryDateRevenueCOGS
2NorthA. ReidHardware15/01/2026£8,400£5,190
3SouthB. ShawSoftware22/01/2026£12,200£3,480
4WestC. FoxServices03/02/2026£6,750£2,550
5NorthA. ReidSoftware14/02/2026£9,800£2,940
6… 476 more transaction rows
Goal: Revenue and gross margin by Region × Category, grouped by Quarter. The source data is valid, but the field placement is still undefined.
After — pivot layout matches the reporting goal
ExcelPivotTable AnalyzeDesignInsert Slicer
ABCDE
3RegionHardwareSoftwareServicesGrand Total
4North£312,400£198,750£84,200£595,350
5GM %38.2%71.4%62.1%52.7%
6South£274,100£143,600£61,800£479,500
7GM %41.0%68.9%58.4%51.6%
8West£198,600£112,400£47,300£358,300
The PivotTable values shown here are illustrative. The page does not show the full 480-row source, so the £ totals and GM% cells cannot be independently reconciled from this example alone. Verify at least one region/category against source Revenue and COGS totals.
RowsRegion
ColumnsCategory
ValuesSum of RevenueGM %
Filters / groupingDate → Quarter
Classic PivotTable calculated field — if supported
Name: GM_Pct
Formula: =(Revenue-COGS)/Revenue
Format: Percentage, 1 decimal place

Why it works for this metric:
the calculated field uses the aggregated Revenue and COGS
for each PivotTable cell, then divides.

If the PivotTable uses the Data Model / OLAP source,
use the appropriate measure approach instead.

Slicer: Region or Quarter ✓
Before — averaging row-level percentages produces the wrong total
ExcelPivotTable AnalyzeField Settings
E5
fx
Average of source helper column Row GM%
ABCDE
3RegionRevenueCOGSRow GM%Pivot GM%
4North£420,000£189,00055.0%55.0%
5South£180,000£126,00030.0%30.0%
6Grand Total£600,000£315,00042.5%
42.5% is the simple average of the two displayed row-level percentages. For this business metric, the required Grand Total is the ratio of aggregated totals: (£600k−£315k) ÷ £600k = 47.5%.
After — classic calculated field produces ratio of aggregated totals
ExcelPivotTable AnalyzeFields, Items & SetsCalculated Field
GM_Pct
fx
=(Revenue-COGS)/Revenue
ABCD
3RegionRevenueCOGSGM_Pct
4North£420,000£189,00055.0%
5South£180,000£126,00030.0%
6Grand Total£600,000£315,00047.5%
Verification
Gross profit = £600,000 − £315,000 = £285,000
GM % = £285,000 / £600,000 = 47.5% ✓

For this metric, do not use Average of a row-level GM% helper column as the Grand Total.
Classic calculated fields operate on summed underlying fields, which is why
=(Revenue-COGS)/Revenue produces 47.5% here.

If the PivotTable is Data Model / OLAP-based, use a measure instead.
Before — spaces, aliases and blanks split the Region field
ExcelHomeDataPivotTable
A4
fx
north region
ABC
1RegionRevenuePivot row
2North£312,400North
3North £84,200North 
4north region£28,100north region
5(blank)£14,600(blank)
6South£274,100South
North-related revenue is split by an extra-space label and an alias. The blank £14,600 cannot safely be assigned to North unless another field proves that mapping.
After — helper column standardises known labels and isolates blanks
ExcelHomeFormulasData
C2
fx
=IF(TRIM(A2)="","Unknown",IF(OR(LOWER(TRIM(A2))="north",LOWER(TRIM(A2))="north region"),"North",PROPER(TRIM(A2))))
ABCD
1Region rawRevenueRegion cleanPivot result
2North£312,400NorthNorth
£424,700
3North £84,200North
4north region£28,100North
5(blank)£14,600UnknownUnknown £14,600
6South£274,100SouthSouth £274,100
Safe cleaning logic
=IF(TRIM(A2)="","Unknown",
   IF(OR(LOWER(TRIM(A2))="north",
         LOWER(TRIM(A2))="north region"),
      "North",
      PROPER(TRIM(A2))))

North total:
£312,400 + £84,200 + £28,100 = £424,700 ✓

The explicit mapping avoids accidentally classifying unrelated labels such as "Northwest".
Blank stays Unknown until you have evidence for its region.
Refresh the PivotTable after filling the helper column.
Four common reasons a PivotTable result looks wrong
Dates stored as text
No Group by Month option → all dates appear individually in rows
High risk
Inconsistent labels
"North " and "north region" can create separate items unless you standardise or explicitly map them
High risk
Subtotals in source data
Pre-calculated subtotal rows → Grand Total double-counts them
Easy fix
Wrong calculated field
Using Average of row-level GM% → wrong weighted percentage at totals
Invisible

How to build a Pivot Table report step by step

Create pivot table reports with ChatGPT — 4 steps
1

Clean your source data before running the prompt

Remove subtotal rows, unmerge header cells, and give every column a unique name. Check that date cells contain real Excel date serial values, not text that merely looks like a date. Number formatting alone does not convert text into a real date, and text dates can prevent reliable date grouping. Fix these first or the pivot will produce wrong results regardless of what ChatGPT specifies.

2

Paste 5–10 rows of real data into the prompt

ChatGPT uses your actual column names in the layout instructions — "put Region in Rows, Category in Columns" — which is far easier to follow than generic instructions. A sample of 5–10 rows is enough; you don't need to paste the entire dataset.

3

State your reporting goal, not your technical requirements

"Revenue by region and category with gross margin, filtered to current year" is a useful goal, but also provide the actual headers, source type, and any business definition that is not obvious from the column names. ChatGPT can then propose field placement, summarisation, number formats, and sort order for you to verify.

4

Verify calculated fields at the total row, not individual rows

Validate percentage metrics at both detail and Grand Total level. First decide what the business definition requires: a ratio of aggregated totals, an average of row-level ratios, or something else. A classic calculated field uses aggregated underlying fields; a source helper column is aggregated according to its Value Field Settings; a Data Model PivotTable may require a measure.

Tip: TRIM handles ordinary extra spaces, while PROPER only changes presentation case. For aliases such as "north region" → "North", use an explicit mapping rule or lookup table rather than a broad substring test that could also catch unrelated labels.
Add calculated fields — 3 steps
1

Confirm the PivotTable source type

Classic calculated fields are available for supported non-OLAP PivotTables. If the PivotTable uses the Data Model or an OLAP source, use the appropriate measure/calculation workflow instead of assuming the Calculated Field command is available.

2

Open Calculated Field only when supported

For a classic supported PivotTable, use PivotTable Analyze → Fields, Items & Sets → Calculated Field. If that command is unavailable because of the source type, do not force this method.

3

Enter the formula and verify the total

Use source field names—not worksheet cell references—in the formula. After adding the metric, independently calculate one subtotal and the Grand Total from the underlying fields to confirm the PivotTable behavior matches the business definition.

Debug pivot issues — 3 steps
1

Identify the broken column

Find which specific row, column, or filter is generating blanks, errors, or splitting identical categories in your pivot.

2

Query ChatGPT with raw data

Copy the prompt and provide ChatGPT with a few raw data lines specifically for that problematic column.

3

Apply fix and refresh

Apply the suggested data cleaning formula or setting in your source sheet. Then right-click anywhere inside the pivot table and click Refresh to see the fix applied.

Frequently asked questions

Can ChatGPT build the actual pivot table inside Excel for me?
ChatGPT does not directly edit your Excel workbook. Paste your data, or upload a file if the ChatGPT interface and plan you are using supports it, and ChatGPT can propose the field layout and calculated-field formulas for you to build in Excel. In all cases, verify field placement, source ranges, calculated metrics, and totals before relying on the report.
What data format does ChatGPT need for pivot table design?
A flat table — one row per transaction or record, with consistent column headers. Merged cells, subtotal rows, and blank header columns will cause problems. If your source data has any of these, describe them in the prompt and ChatGPT will suggest a cleaning step before designing the pivot.
How do I add a calculated field like gross margin % to a pivot table?
Use the Calculated Field tab above. ChatGPT writes the exact formula for the PivotTable Analyze → Fields, Items & Sets → Calculated Field dialog. For classic non-OLAP PivotTables, calculated fields operate on aggregated underlying fields. ChatGPT should first determine whether that behavior matches your metric and whether the PivotTable source supports classic calculated fields; Data Model/OLAP PivotTables may require a measure instead.
My pivot table shows (blank) rows — how do I fix this?
A “(blank)” item often indicates blank source values in that field, but confirm the source and refresh state before assuming that is the only cause. Use the Debug tab above — paste a sample of the column causing the issue and ChatGPT identifies the fix, typically a find-and-replace or a helper column that fills missing values before the pivot is built.
Can I use ChatGPT to redesign an existing pivot table report?
Yes. Describe the current layout and what's wrong — too many rows, wrong grouping, a missing metric — and ChatGPT specifies a revised structure. Paste a sample of the underlying data so ChatGPT references your actual column names rather than working from a description alone.

Related Excel workflows