Skip to content

Let AI do the totals instead of a pivot table

You don't need to know the PivotTable menus: describe the rows, columns and values, and the assistant writes the formula. The numbers come from the sheet or from code, never from the chat, and you check them against the source.

PracticalOffice workersMarketers

12 minAs of Oct 2026

By the end of this guide

  • Describe rows, columns and values to get a PIVOTBY or SUMIFS formula for your summary.
  • When you use a file-analysis feature, get the code, row count and total back so you can check them.
  • Check the summary against the source totals and keep it as a table you can reuse every week.
Illustration of a source sheet with color-coded region dots leading to a summary grid under an AI-written formula bar, with a dashed line and an equals sign linking the sheet's Σ total to the grid's checked grand total
Illustration: AI Ping

Who this is for

  • Anyone who has to relearn PivotTables every time
  • Anyone who builds a sales-by-region-and-product table every week

What you need

  • Excel or Google Sheets (some Excel versions don't have the PIVOTBY function)
  • Any chat assistant (free versions work); file-analysis features depend on the service and plan
  • Reading "Write spreadsheet formulas with AI" first will help.

Step by step

  1. Check the data shape first

    However good the formula, the totals come out wrong if the source isn't in a shape that can be summarized. Microsoft's guidance for PivotTable data says the same: columns with a single header row, and no double header rows or merged cells.

    Text mixed into a number column fails more quietly. A PivotTable shows that field as a count instead of a sum, and Google Sheets' QUERY function treats values that don't match a column's main type as empty.

    What to check before you summarize
    CheckTrouble looks likeFix
    HeaderTwo header rows, or merged cellsOne header row in row 1; unmerge
    One row per recordSubtotal or total rows in the middleDelete them; totals belong in the summary
    Consistent names"Seoul" and "Seoul City", stray spacesFind and replace to one spelling
    Number formatNumbers stored as text, sitting on the left of the cellConvert them (see "Write spreadsheet formulas with AI")

    Check it

    • Open the filter list on the region and product columns and look for near-duplicates such as "Seoul" and "Seoul City".
  2. Describe rows, columns and values, then get a formula

    Rather than "make me a pivot table," describe the rows, columns and values: "regions down the side, products across the top, total revenue in the cells."

    And ask for a formula, not the numbers. Sums an assistant works out in the chat can be wrong (see long calculations in "Why AI gets things wrong"), while a formula in the sheet works from the source and recalculates when the source changes.

    The example sheet used in this guide (made-up October sales, rows 2–11)
    DateRegionProductQtyRevenue
    2026-10-01SeoulTumbler12180,000
    2026-10-01BusanMug20180,000
    2026-10-02DaeguTumbler8120,000
    2026-10-02SeoulMug15135,000
    2026-10-05BusanTumbler10150,000
    2026-10-05SeoulTumbler690,000
    2026-10-06DaeguMug12108,000
    2026-10-07SeoulMug981,000
    2026-10-08BusanMug14126,000
    2026-10-08DaeguTumbler575,000
    Example prompt
    Here is my spreadsheet layout.
    Column A: Date, B: Region, C: Product, D: Qty, E: Revenue (number)
    Data runs from row 2 to row 11.
    I want a summary starting in cell G2, with regions as rows, products as columns and total revenue as the values. Give me the formula for Excel for Microsoft 365. Don't calculate any numbers yourself, just the formula.
    Example AI reply

    PIVOTBY groups and aggregates data in two directions at once. Put the formula below in G2 and it spills a table of revenue by region and product, with total rows and columns included.

    Only some Excel versions have PIVOTBY. If you get #NAME?, use the SUMIFS approach instead.

    =PIVOTBY(B2:B11, C2:C11, E2:E11, SUM)
    B2:B11
    Row groups: the regions in column B
    C2:C11
    Column groups: the products in column C
    E2:E11
    Values to aggregate: revenue in column E
    SUM
    Add them up (AVERAGE or COUNT give averages or counts)

    Check it

    • If you pasted the formula exactly and still see #NAME?, your Excel doesn't have PIVOTBY. Move on to the SUMIFS method in the next step.
  3. No PIVOTBY? Build a SUMIFS grid

    SUMIFS works in practically every version of Excel and in Google Sheets. Type the region and product names into an empty grid, fill the cells with SUMIFS, and you have the same summary.

    In Google Sheets you can also build it with a single QUERY formula, such as =QUERY(A1:E11, "select B, sum(E) group by B pivot C", 1).

    Example prompt
    I get #NAME? when I use PIVOTBY, so I deleted it and typed Seoul, Busan and Daegu in G3:G5, and Tumbler and Mug in H2:I2. Give me one SUMIFS formula for H3 that I can fill across H3:I5. Just the formula, no calculations.
    Example AI reply

    Put this in H3 and fill it across H3:I5. Thanks to the $ signs, each cell picks up the region in its row and the product in its column. Add totals yourself, such as =SUM(H3:H5), and it all works the same in Google Sheets.

    =SUMIFS($E$2:$E$11, $B$2:$B$11, $G3, $C$2:$C$11, H$2)
    $E$2:$E$11
    What to add: revenue, with row and column both fixed
    $B$2:$B$11, $G3
    Condition 1: the region matches column G; only the column is fixed
    $C$2:$C$11, H$2
    Condition 2: the product matches row 2; only the row is fixed

    Check it

    • After filling, click I5 and check that its formula reads =SUMIFS($E$2:$E$11, $B$2:$B$11, $G5, $C$2:$C$11, I$2). That's the Daegu and Mug cell.
  4. Uploading a file? Ask for the code and the totals

    Some assistants can also run code on a file you upload, such as an Excel file or a CSV. Claude, for example, can analyze an uploaded CSV with code. Availability depends on the service, your plan and your organization's settings, and for company data, check your company's rules first.

    The numbers should then come from the code. Ask for the code it ran, the number of rows it read and the revenue total, so you have something to check against the source. The sales.csv below holds the same data as the example sheet in step 2.

    Example prompt
    Use the sales.csv I uploaded to make a table of total revenue by region and product. Do the calculation by running code, and show me the code, the number of rows you read and the total revenue.
    Example AI reply

    I calculated this by running code. It read 10 rows, and total revenue is 1,245,000.

    Here's the code I ran. "Total" in the table is the All row and column in its output.

    Example code
    import pandas as pd df = pd.read_csv("sales.csv") print(len(df), df["Revenue"].sum()) print(df.pivot_table(index="Region", columns="Product", values="Revenue", aggfunc="sum", margins=True))
    Revenue by region and product, as calculated by the code (example)
    RegionMugTumblerTotal
    Busan306,000150,000456,000
    Daegu108,000195,000303,000
    Seoul216,000270,000486,000
    Total630,000615,0001,245,000

    Check it

    • Compare the row count (10) and total (1,245,000) with the source sheet's row count and =SUM(E2:E11). If they differ, check the uploaded file first.
  5. Check against the source, then keep it reusable

    However you built the summary, run these four checks before you share it. Comparing totals catches missing rows; counting numbers catches values stored as text.

    For a weekly report, keep formulas or a PivotTable rather than pasting in the results. Formulas recalculate when the source changes, and a PivotTable picks up new data when you refresh it.

    Checks before you share (for the example sheet)
    CheckHowIn this example
    Grand totalThe summary's total equals =SUM(E2:E11) on the source1,245,000
    Count of numbers=COUNT(E2:E11) equals the number of data rows (text numbers make it smaller)10
    One cell by handPick a cell and add up its source rows yourselfSeoul, Tumbler: 180,000 + 90,000 = 270,000
    Split namesThe summary has as many regions and products as you expect3 regions, 2 products

    Check it

    • After pasting in next week's data, repeat the total and count checks. If the formula ranges (such as E2:E11) don't grow with the data, the new rows are left out.

Common mistakes

  • Copying totals the assistant worked out in the chat straight into a report
  • Summarizing with mixed names such as "Seoul" and "Seoul City"
  • Pasting results instead of formulas into a report you update every week

References

Keep learning

  • How-to guide12 min

    AI drafts, people finish: a blog workflow

    A blog workflow where AI handles the outline and first draft, and people handle the plan, the fact-checking, the real experience and the final check.

    BeginnerMarketersOffice workers
  • How-to guide9 min

    Get a three-line summary of a long report

    Tell the assistant who will read it and what shape the three lines should take, and a long report comes back as a summary you can pass straight on. This guide also shows how to check its figures against the original.

    BeginnerOffice workersBeginners