Ravindra BagaleCourses & study guides मराठी Track your progress

How to Create a PivotTable in Excel for Beginners: Rows, Values, Count vs Sum and Report Filter (Blinkit Orders Example)

So far every summary in this course was a formula: COUNTIFS, SUMIFS, UNIQUE. A PivotTable builds the same summaries by dragging column names into boxes, with no formula at all, and changes its answer the moment you drag a different column. In this chapter you build your first pivots on the 24 made-up orders: count of orders, city-wise profit, orders by payment mode and status, and profit of delivered orders only.

What you'll learn in this chapter

  • Where PivotTables fit: raw data to dashboard
  • Insert a PivotTable from a table (two ways)
  • The four boxes: Filters, Columns, Rows, Values
  • Text in Values gives Count; numbers give Sum
  • City-wise profit with a Grand Total
  • Several pivots on one sheet, and a report filter for Status = Delivered

Practice file: excel-first-pivottable-practice.xlsx: Orders (the table named Orders) and Pivot answers (every pivot result in this chapter, worked out with formulas so you can check yours).

Made-up data: the 24 orders are made up for practice. They imitate a quick-commerce app such as Blinkit or Amazon Now in Pune, Nashik, Solapur, Kolhapur, Nagpur and Sambhaji Nagar.

1. From raw data to a dashboard

A dashboard is built in steps, and each step uses what you learned before:

  1. Raw data: the orders as they arrive, in a plain range.
  2. Excel Table: Ctrl+T, a name, filters (Table vs Range).
  3. PivotTables: summaries by city, payment mode, status (this chapter).
  4. Pivot Charts and KPI cards: charts and big single numbers built on the pivots.
  5. Dashboard: all of it on one screen.

Classroom line

In the end we build a dashboard. Everything should be visible on a single screen.

Before you build anything, decide what you want to know: how many orders, profit by city, how many were paid online, how many were delivered late. Each question becomes one pivot.

Classroom line

You have to decide what all you want to analyse.

From raw data to a dashboard Raw data plain range Excel Table Ctrl+T, a name PivotTable summaries Pivot Charts + KPI cards Dashboard one screen This chapter: step 3. Steps 1 and 2 are the earlier table chapters.

Figure 1. The workflow: Raw data → Excel Table → PivotTable → Pivot Charts and KPI cards → Dashboard on one screen.

2. Insert a PivotTable

  1. Click any cell inside the Orders table.
  2. Insert > PivotTable (in Excel 365 choose From Table/Range), or Table Design > Summarize with PivotTable.
  3. Table/Range already says Orders.
  4. Choose New Worksheet and click OK.

A new sheet opens with an empty pivot area on the left and the PivotTable Fields pane on the right. The top of the pane lists the 13 column names; the bottom has four boxes:

  1. Filters: limits the whole pivot to some values (a report filter).
  2. Columns: values across the top.
  3. Rows: values down the side.
  4. Values: the numbers being counted or added.

Using the table name as the source means new orders added to the table are included the next time you click PivotTable Analyze > Refresh.

3. Values: Count or Sum?

  1. Drag Order_ID into Values. The pivot shows Count of Order_ID: 24. Order IDs are text: they cannot be added, so Excel counts them.
  2. Remove it (drag it out of the box) and drag Profit into Values: Sum of Profit: 327. Profit is a number, so Excel adds it.

Classroom line

What would I do with the order IDs themselves? I only need their count.

The rule: text and dates go to Rows (or Columns, or Filters); numbers go to Values. A text column dropped in Values is counted; a number column is summed. To change it, click the field in Values > Value Field Settings and pick Sum, Count, Average, Max or Min.

4. City-wise profit

  1. Drag City into Rows.
  2. Keep Profit in Values.
Row Labels Sum of Profit
Kolhapur 64
Nagpur 154
Nashik 36
Pune 6
Sambhaji Nagar 61
Solapur 6
Grand Total 327
  1. Each city appears once, even though Pune has 6 orders: the pivot groups them.
  2. The cities are sorted A to Z.
  3. Grand Total is added for you.

When you tick a text field's box in the pane instead of dragging, Excel puts it in Rows by itself.

Classroom line

If it is a text column, it goes to Rows, not to Values.

Drag City to Rows and Profit to Values PivotTable Fields Filters Columns Rows City Values Sum of Profit Row Labels Sum of Profit Kolhapur 64 Nagpur 154 Nashik 36 Pune 6 Sambhaji Nagar 61 Solapur 6 Grand Total 327 Sorted A to Z Each city once Text → Count, numbers → Sum

Figure 2. City in Rows and Profit in Values give one row per city, sorted A to Z: Kolhapur 64, Nagpur 154, Nashik 36, Pune 6, Sambhaji Nagar 61, Solapur 6, Grand Total 327.

Ravindra Bagale's Tip

Check every new pivot against one number you already know. Here the Grand Total must be 327, the same as =SUM(Orders[Profit]). If it isn't, a field is in the wrong box or the source range is wrong.

5. More pivots on the same sheet

You can build another pivot next to the first one without starting again:

  1. Click inside the first pivot, then PivotTable Analyze > Select > Entire PivotTable.
  2. Press Ctrl+C.
  3. Click an empty cell a few columns to the right, for example D3, and press Ctrl+V.
  4. Click inside the copy and change its fields: remove City and Profit, put Payment_Mode in Rows and Order_ID in Values.

Or insert a fresh one: Insert > PivotTable, choose Existing Worksheet, click in Location and click the cell where it should start (Excel writes something like Sheet2!$D$3), then OK.

Leave at least one empty column between pivots: a pivot that grows must not run into its neighbour.

Pivot Rows Values Result
2 Payment_Mode Count of Order_ID COD 9, Online 15
3 Delivery_Status Count of Order_ID Late 6, On Time 15, (blank) 3
4 Status Count of Order_ID Cancelled 3, Delivered 18, Returned 3

Each Grand Total is 24. In pivot 3, (blank) is the 3 cancelled orders, which were never delivered and so have no Delivery_Status.

Four pivots on one sheet (one empty column between them) City / Sum of Profit Row Labels Profit Kolhapur 64 Nagpur 154 Nashik 36 Pune 6 Sambhaji Nagar 61 Solapur 6 Grand Total 327 Payment_Mode / Count Row Labels Count COD 9 Online 15 Grand Total 24 Delivery_Status / Count Row Labels Count Late 6 On Time 15 (blank) 3 Grand Total 24 Status / Count Row Labels Count Cancelled 3 Delivered 18 Returned 3 Grand Total 24

Figure 3. Four pivots side by side: city-wise profit, orders by payment mode (COD 9, Online 15), by delivery status (Late 6, On Time 15, blank 3) and by status (Cancelled 3, Delivered 18, Returned 3).

6. Report filter: profit of delivered orders only

The city-wise profit in section 4 includes cancelled and returned orders. Nagpur's 154 contains 100 from a cancelled order (ORD1006) that never earned anything.

  1. Click inside the city-wise profit pivot.
  2. Drag Status into Filters. A filter cell appears above the pivot: Status (All).
  3. Open it, choose Delivered, click OK.
Row Labels Sum of Profit
Kolhapur 60
Nagpur 54
Nashik 20
Pune 14
Sambhaji Nagar 65
Solapur 14
Grand Total 227

The best city changes from Nagpur to Sambhaji Nagar once only delivered orders count. This is the same answer as =SUMIFS(Orders[Profit],Orders[Status],"Delivered") from the SUMIFS chapter, built without a formula.

Report filter: Status = Delivered All orders Row Labels Sum of Profit Kolhapur 64 Nagpur 154 Nashik 36 Pune 6 Sambhaji Nagar 61 Solapur 6 Grand Total 327 Status Delivered ▼ Row Labels Sum of Profit Kolhapur 60 Nagpur 54 Nashik 20 Pune 14 Sambhaji Nagar 65 Solapur 14 Grand Total 227 Nagpur 154 included a cancelled order worth 100 (ORD1006). Delivered only: best city is Sambhaji Nagar, 65. Same as =SUMIFS(Orders[Profit], Orders[Status],"Delivered") = 227

Figure 4. Status in Filters set to Delivered. Profit by city drops to Kolhapur 60, Nagpur 54, Nashik 20, Pune 14, Sambhaji Nagar 65, Solapur 14, Grand Total 227.

7. The whole chapter on one page

Box Put here Example
Rows text or dates to group by City
Columns a second grouping across the top Payment_Mode
Values numbers to add, or anything to count Sum of Profit, Count of Order_ID
Filters a condition for the whole pivot Status = Delivered
  1. Raw data → Table → PivotTable → Pivot Charts and KPI cards → Dashboard.
  2. Insert > PivotTable from the table, New Worksheet.
  3. Text in Values = Count; numbers in Values = Sum.
  4. Pivots group, sort A to Z and add a Grand Total.
  5. Copy a pivot with Select > Entire PivotTable, Ctrl+C, Ctrl+V; or Existing Worksheet + Location.
  6. A report filter answers "for delivered orders only".

8. Try at home

Try at home

Task 1

  1. Build a pivot with Product_Name in Rows and Quantity in Values. What is the Grand Total? (81.)

Task 2

  1. In the city-wise profit pivot, set the Status filter to Returned. Which cities appear? (Kolhapur 4, Nashik 16 and Pune −8; Grand Total 12.)

Task 3

  1. Put City in Rows, Payment_Mode in Columns and Order_ID in Values. How many Online orders does Pune have? (5.)

9. Going further: a second practice table

Sections 1 to 8 used the 24 grocery orders. The next sections need a Revenue and a Cost column, so we use a small shop sales table instead. It has 12 rows, one row per sale, and is saved as an Excel Table named Sales (Ctrl+T, then type the name in Table Design > Table Name).

Order_IDOrder_DateCityCategorySalespersonRevenue (₹)Cost (₹)
S10105-01-2026PuneGroceryShahrukh12,0009,000
S10212-01-2026NashikFashionZoya18,00012,000
S10320-01-2026PuneElectronicsRaja45,00038,000
S10403-02-2026NagpurGroceryRani9,0007,000
S10510-02-2026KolhapurFashionZoya15,00010,000
S10618-02-2026PuneFashionShahrukh21,00014,000
S10725-02-2026NashikElectronicsRaja30,00026,000
S10804-03-2026NagpurElectronicsRani36,00030,000
S10911-03-2026KolhapurGroceryShahrukh8,0006,000
S11019-03-2026PuneGroceryZoya14,00010,000
S11124-03-2026NashikGroceryRani6,0004,500
S11230-03-2026KolhapurElectronicsRaja26,00022,000
Total2,40,0001,88,500

Made-up data for practice: every name, city figure and amount is made up. Download it: pivottable-going-further-practice.xlsx (sheet Sales = the table above; sheet Answers = every result below worked out with formulas, so you can check your pivots).

Before you build a pivot on any data of your own, check the source once:

  1. Row 1 has a heading for every column, and no two headings are the same.
  2. There are no fully blank rows or columns inside the data.
  3. Revenue and Cost are real numbers, not text (numbers sit on the right of the cell).
  4. Dates are real Excel dates, not text, or they cannot be grouped into months later.
  5. The data is an Excel Table with a clear name such as Sales. Ctrl+T makes a Table, not a PivotTable: the Table is the source, the PivotTable is the summary.

A PivotTable never changes this source data. It only reads it and builds a summary you can rearrange.

10. Each city's share of total revenue (% of Grand Total)

Question: Pune sells the most, but what share of all revenue does it bring? You do not need a formula for this.

  1. Click inside the Sales table, then Insert > PivotTable > New Worksheet > OK.
  2. Drag City into Rows.
  3. Drag Revenue into Values. Drag Revenue into Values a second time. You now have Sum of Revenue and Sum of Revenue2.
  4. Right-click any number in the Sum of Revenue2 column.
  5. Choose Show Values As > % of Grand Total.
  6. Click the heading cell of that column and type a clear name: Revenue Share %.
Row LabelsSum of RevenueRevenue Share %
Kolhapur49,00020.42%
Nagpur45,00018.75%
Nashik54,00022.50%
Pune92,00038.33%
Grand Total2,40,000100.00%

Pune's share is 92,000 ÷ 2,40,000 = 38.33%. The shares always add up to 100%. The same menu has Running Total In: once dates are grouped by month (see Group dates by month), it shows January 75,000, February 1,50,000, March 2,40,000.

11. Show only the top 3 cities (Value Filters)

  1. Use the pivot from section 10 (City in Rows, Sum of Revenue in Values).
  2. Click the drop-down arrow on the Row Labels cell.
  3. Choose Value Filters > Top 10.
  4. Change 10 to 3, keep Items and Sum of Revenue, click OK.

Result: Pune 92,000, Nashik 54,000 and Kolhapur 49,000. Nagpur is hidden, and the Grand Total now shows only the visible cities: 1,95,000. On a big table, use the same steps with 5 for a "Top 5 products" report. To remove it: drop-down arrow > Clear Filter From "City".

12. Profit and margin with a Calculated Field

The Sales table has Revenue and Cost but no Profit column. A Calculated Field is a new field you create inside the PivotTable with a formula that uses other fields.

  1. Build a pivot: Category in Rows, Revenue and Cost in Values.
  2. Click inside the pivot, then PivotTable Analyze > Fields, Items & Sets > Calculated Field.
  3. In Name type Profit.
  4. In Formula type =Revenue-Cost (double-click a field in the list to insert its name).
  5. Click Add.
  6. Now type Margin in Name and =(Revenue-Cost)/Revenue in Formula, click Add, then OK.
  7. Right-click a Margin number > Number Format > Percentage, 1 decimal place.
Row LabelsSum of RevenueSum of CostSum of ProfitSum of Margin
Electronics1,37,0001,16,00021,00015.3%
Fashion54,00036,00018,00033.3%
Grocery49,00036,50012,50025.5%
Grand Total2,40,0001,88,50051,50021.5%

A calculated field always works on the totals of each row of the pivot. Grocery's margin is 12,500 ÷ 49,000 = 25.5%: total profit divided by total revenue. That is the correct margin.

The wrong way is to work out a margin % on every sale and then average those percentages. Grocery's five sales have margins 25%, 22.2%, 25%, 28.6% and 25%; their average is 25.2%, not 25.5%. The small sales count as much as the big ones, so the average is off. Always divide total profit by total revenue.

A calculated field cannot use cell references like A2, and it always adds (Sum) first. Keep its formulas to simple field maths like the two above.

Ravindra Bagale's Tip

Check the Grand Total of Profit against a number you already know: 2,40,000 − 1,88,500 = 51,500. If the pivot shows something else, the formula in the calculated field is wrong.

Same margin with the Data Model (DAX measure). If you tick Add this data to the Data Model in the Create PivotTable box, Calculated Field is not available. Instead you add a measure: right-click the table name Sales in the PivotTable Fields pane > Add Measure. A measure is a formula written in DAX, the formula language of the Data Model. If your table has a Profit column, the margin measure is:

Profit Margin := DIVIDE(SUM(Sales[Profit]), SUM(Sales[Revenue]))

In our Sales table there is no Profit column, so write it as Profit Margin := DIVIDE(SUM(Sales[Revenue]) - SUM(Sales[Cost]), SUM(Sales[Revenue])). DIVIDE divides the first number by the second and shows a blank instead of an error when revenue is 0. Format the measure as a percentage. The result is the same: Grocery 25.5%. More on this in Power Pivot and the Data Model.

13. Count unique salespeople (Distinct Count)

Question: how many different salespeople sold in each city? Normal Count counts rows, so Pune would show 4 (four sales), but only 3 people made them.

  1. Click inside the Sales table, Insert > PivotTable.
  2. Tick Add this data to the Data Model, choose New Worksheet, click OK.
  3. Drag City into Rows and Salesperson into Values.
  4. Click Count of Salesperson in Values > Value Field Settings > choose Distinct Count > OK.

Result: Kolhapur 3, Nagpur 1, Nashik 3, Pune 3. The Grand Total is 4, not 10, because only four different people (Shahrukh, Zoya, Raja, Rani) appear in the whole table. Distinct Count appears in the list only when the pivot uses the Data Model.

14. Pull one pivot number into a cell (GETPIVOTDATA)

GETPIVOTDATA reads one value out of a PivotTable, for example to show it in a report cell. Say the city pivot from section 10 starts at cell A3 (Row Labels is in A3):

=GETPIVOTDATA("Revenue",$A$3,"City","Pune")
  1. "Revenue" = the value field to read (Sum of Revenue).
  2. $A$3 = any cell inside the pivot, so Excel knows which pivot.
  3. "City","Pune" = the row to read: City is Pune.

Result: 92000. You rarely type it: in an empty cell type = and click Pune's revenue in the pivot, and Excel writes the GETPIVOTDATA formula for you. Unlike a plain =B7, it still finds Pune after the pivot is sorted or filtered. The KPI card chapter uses it for dashboard cards.

15. Common PivotTable mistakes and fixes

What you seeWhyFix
Count of Revenue instead of SumSome revenue cells are text or blankMake them real numbers, then Value Field Settings > Sum
New rows are missingThe pivot was built on a fixed range, or not refreshedBuild it on a Table and click PivotTable Analyze > Refresh
Old numbers after editing the dataA pivot does not update by itselfRight-click the pivot > Refresh
Dates will not group into monthsText dates or blank date cellsTurn them into real dates, fill the blanks
No Distinct Count in the listThe pivot is not on the Data ModelRebuild it with Add this data to the Data Model ticked
Margin looks wrongPercentages were averagedTotal profit ÷ total revenue (section 12)

16. 20 pivot questions, from beginner to expert

Every question below can be answered on the Sales table by moving fields, without SUMIFS or COUNTIFS. Try them in order.

No.LevelQuestionHow
1BeginnerTotal revenue by cityRows City, Values Sum of Revenue (Pune 92,000)
2BeginnerNumber of sales by salespersonRows Salesperson, Values Count of Order_ID (3 each)
3BeginnerAverage sale by cityValue Field Settings > Average (Pune 23,000)
4BeginnerTotal cost by categoryRows Category, Values Sum of Cost (Grocery 36,500)
5BeginnerRevenue of Grocery onlyCategory in Filters = Grocery (49,000)
6IntermediateCategory revenue in each cityRows City, Columns Category (cross-tab chapter)
7IntermediateBest salesperson firstSort Largest to Smallest (sort chapter): Raja 1,01,000
8IntermediateTop 3 citiesValue Filters > Top 10 set to 3 (section 11)
9IntermediateRevenue by monthOrder_Date in Rows, grouped by Months (group dates chapter)
10IntermediateEach city's share of revenueShow Values As > % of Grand Total (section 10)
11AdvancedFilter by city with buttonsSlicer on City (slicers chapter)
12AdvancedRevenue between two datesTimeline on Order_Date (PivotTables chapter)
13AdvancedRevenue and cost side by side as a chartTwo Values fields + Pivot Chart (Pivot Chart chapter)
14AdvancedProfit margin by categoryCalculated Field (section 12): Fashion 33.3%
15AdvancedRunning total by monthShow Values As > Running Total In (section 10)
16ExpertUnique salespeople per cityData Model + Distinct Count (section 13)
17ExpertJoin sales with a second table, e.g. store detailsRelationships in the Data Model (Data Model chapter)
18ExpertOne-screen management dashboardPivot Charts + slicers + timeline (KPI card chapter)
19ExpertShow one pivot result in a report cellGETPIVOTDATA (section 14)
20ExpertMargin across several tablesDAX measure with DIVIDE (section 12)

17. PivotTable interview questions

What is the difference between an Excel Table and a PivotTable?
An Excel Table holds and organises the source rows (Ctrl+T). A PivotTable reads those rows and shows a summary you can rearrange.

What is the difference between a report filter and a slicer?
Both filter the pivot. A slicer shows clickable buttons, shows what is selected at a glance, and one slicer can control several pivots built on the same source (Slicer > Report Connections).

Can one PivotTable show several Values fields?
Yes. Section 12 shows Sum of Revenue, Sum of Cost, Profit and Margin in one pivot.

What does GETPIVOTDATA do?
It returns one value from a pivot by field and item names, for example =GETPIVOTDATA("Revenue",$A$3,"City","Pune") = 92000.

Calculated field or DAX measure?
A calculated field works in a normal PivotTable and uses simple field maths on totals. A DAX measure works in a Data Model pivot and can do more, such as Distinct Count style logic, relationships between tables and safe division with DIVIDE.

Does a PivotTable update by itself when the data changes?
No. Click PivotTable Analyze > Refresh (or right-click > Refresh).

18. Practice on the Sales table

Try at home

Task 4

  1. Category in Rows, Revenue in Values twice, the second one as % of Grand Total. What is Electronics' share? (57.08%.)

Task 5

  1. Salesperson in Rows, add the Profit calculated field. Who earned the most profit? (Raja and Zoya tie at 15,000.)

Task 6

  1. Add the Margin calculated field to the Salesperson pivot. Whose margin is highest? (Zoya, 31.9%.)

Task 7

  1. With Data Model ticked, Category in Rows and Distinct Count of Salesperson. How many people sold Grocery? (3: Shahrukh, Zoya, Rani.)

Recap

In short

  1. A PivotTable summarizes a table by dragging fields into Rows, Columns, Values and Filters.
  2. Text in Values is counted; numbers are summed.
  3. City-wise profit: City in Rows, Profit in Values, Grand Total 327.
  4. Copy a pivot or use Existing Worksheet to build several on one sheet.
  5. Status in Filters = Delivered gives profit of delivered orders only: 227.
  6. Show Values As > % of Grand Total gives each city's share: Pune 38.33%.
  7. A Calculated Field (=Revenue-Cost) adds Profit; margin = total profit ÷ total revenue, never an average of percentages.
  8. Distinct Count (Data Model) counts different people, GETPIVOTDATA pulls one pivot number into a cell.

Quick revision cards

Quick revision

Revise this chapter in two minutes. Save the cards on your phone or download them as PNG files. All names and numbers are made up for practice.

Revision card: PivotTable basics: count, sum, filter. Example data table with Order ID in Values: Count = 4; City-wise profit: Pune ₹220, Nashik ₹80; Delivered orders only: Pune ₹160.
Card 1 of 2: PivotTable basics: count, sum, filter · Download PNG
Revision card: Pivot areas. Covers Rows; Columns; Values; Filters. With a photo of Ravindra Bagale and a short tip.
Card 2 of 2: Pivot areas · Download PNG

More cards for every chapter: Ravi Sir's Cards.

Loading practice tasks...

  1. Distinct groups (Easy): How many different values in B2:B11?
  2. List groups (Easy): Unique list of B2:B11.
  3. Filter names (Easy): Names in A2:A11 where B is "Snacks".
  4. Sum of filtered (Medium): Sum of D2:D11 where B is "Dairy", using FILTER.
  5. Count filtered (Medium): Rows where D is above the average of D2:D11.
  6. Sorted values (Medium): D2:D11 sorted largest first.
  7. Top value via SORT (Medium): The largest E2:E11 value using SORT and INDEX.
  8. Second largest (Hard): Second largest D2:D11 using SORT and INDEX.
  9. Numbers 1 to 5 (Hard): A spill of numbers 1 to 5.
  10. Two-condition filter (Hard): Sum of D2:D11 where B is "Snacks" or "Dairy".
  11. Names joined (Hard): Names where B is "Snacks", joined with ", ".