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

7. PivotTables and PivotCharts

Excel

7.1 Creating a PivotTable

Create your first PivotTable from a known order list

Imagine supporting a small delivery team during an internship. You have a list of order IDs and their recorded amounts. Your supervisor wants the amount by city and a report that still works when a new order is added. You could calculate a few totals by hand. A PivotTable gives the team a reusable summary when there is a regularly updated source.

The ten orders in this lesson are synthetic. The IDs borrow familiar prefixes from Blinkit and Amazon Now for practice and contain no personal data. This stripped-down version of the chapter fixture uses three columns so you can focus on creating the report. Its Amount column contains each recorded order amount in rupees, across all statuses in the full source. That scope includes more than delivered orders.

  • Source. Decide which rows and measurements belong to the report.
  • Destination. Pick a worksheet where the summary can expand without overlapping other work.
  • Grouping. Put City in Rows so a separate result appears for each city.
  • Calculation. Put Amount in Values and confirm Sum. Compare one group and the grand amount independently.

Put each field into a clean source column

A PivotTable summarises records. It reads the column labels as field names and groups whichever field you choose. A source file often arrives with a title at the top, a row of labels, several blocks of records and a total line at the end. Choose only the rectangular dataset you intend to analyse. Leave visual notes and derived report totals outside its source range.

Choose exactly one usable row of headers

  • Start with the intended field names. In this exercise they are Order ID, City and Amount. Each label appears only once and describes a single kind of information.
  • Keep records below the headers. Each subsequent row represents one actual record at the declared order grain.
  • Remove design features from the source rectangle. Put merged titles outside it. Avoid embedded header rows and visual blank separator rows.
  • Check whether totals already exist. Exclude worksheet subtotals and the repeated grand total from the source observations. The PivotTable computes summaries from legitimate rows.

For example, suppose someone adds a row called All Cities with 2870 beneath the ten order rows and selects it as part of the PivotTable source. The report can see an extra row and include that already calculated number again. The resulting amount 5740 is twice the recorded order amount. A worksheet label might make the duplicate obvious to a person. The selected source rectangle still tells Excel to include the row until you change it.

Inspect the type and meaning of each field

Keep Order ID as text. Its characters identify an order and do not need to take part in arithmetic. Keep City as an approved grouping label. Keep Amount numeric. If a cell shows 1299 but was stored as text, a numerical coverage check can help detect it. Applying a currency display format alone does not guarantee that the underlying cell now holds a number.

If a record lacks a city, decide if an explicit unknown grouping is acceptable or hold the row under your report policy. A blank city is a missing grouping value. A blank amount is a missing measurement. These require different checks. A real zero recorded under the source rule can still be an actual measurement and should remain numeric.

Does the PivotTable solve inconsistent source labels?

The PivotTable groups the values it receives. Resolve or map inconsistent source labels separately under a known definition, then refresh or confirm the result.

Lab 1 · Build the order list and verify a city summary

Goal. Use a clean source and reproduce the six city totals and ₹2,870 grand amount. Create a scratch workbook with an OrdersList worksheet. In A1:C1 write Order ID, City and Amount. Add the ten rows below through row 11. Enter the amounts as plain numbers. Choose your number format after the independent verification.

Single table of practice order records
Order IDCityAmount (₹)
BLK-1001Pune64
BLK-1002Nashik270
AMN-1003Pune110
BLK-1004Nagpur240
AMN-1005Kolhapur232
BLK-1006Pune150
BLK-1007Solapur1299
AMN-1008Sambhaji Nagar195
BLK-1009Pune220
BLK-1010Nashik90

Prove the contents before insertion

In unused scratch cells outside the source, =COUNT(C2:C11) returns 10 and =SUM(C2:C11) gives 2870. Use =SUMIF(B2:B11,"Pune",C2:C11) to check Pune's 544. Check that A2:A11 contains the ten stated IDs. If a control is wrong, fix the known data entry or type in the scratch source before opening the PivotTable tool. One exact total and one group control help you locate errors later.

Insert the report from the named table

  1. Select the data rectangle. Click inside your intended data. Use Insert Table on a supported edition and verify A1:C11 and the option for existing headings. Name the resulting Excel Table tblCityOrders. Check the selected boundaries and three headers.
  2. Choose the source manually. Select a source cell and use Insert and PivotTable on an edition that supports it. Choose the table or range source where prompted. Verify tblCityOrders. For a simple local report, use the conventional table or range route without adding the source to a separate model.
  3. Choose an output location. Select New Worksheet for this exercise. Confirm the destination when prompted and name its sheet Pivot_City. The separate sheet gives room for future columns and rows.
  4. Find the source fields. Click in the new PivotTable and inspect the field list. Order ID, City and Amount should appear. If a field is missing, inspect the source boundaries and header before creating a second PivotTable.
  5. Build the grouping. Put City into Rows. Put Amount into Values and verify the visible summary name matches Sum of Amount. If another operation appears, inspect the source and explicitly use Sum for this measurement.
  6. Verify output by label. Compare Pune, Nashik and the grand total with the independent source. Use the expected report below to locate the other cities. Report order can vary. Match by city rather than by copied row numbers.
A source with Order ID, City and Amount becomes a report with City in Rows and Sum of Amount in Values. Pune has 544 and the total is 2870.
Source fields lead to report groupings and operations. Inspect each stage before relying on the result.
Expected city amounts in the base exercise
CitySum of Amount (₹)
Kolhapur232
Nagpur240
Nashik360
Pune544
Sambhaji Nagar195
Solapur1299
Grand Total2870

Verify and recover. If the report shows one result rather than six city rows, check Rows for City. If the output shows count or no amount, inspect Values and its operation. If the Insert command is unavailable, use a scratch list of distinct cities and SUMIF to rebuild the expected figures by hand. Save the practice baseline, restore unintended filters and use a copy for the next lab.

Trace one result from four source amounts

  1. Identify the intended population

    The source is ten recorded order rows. There is no additional all-cities source total and all ten amounts are numeric.

  2. Give the grouping a label

    City in Rows creates results for each matching city. In the input find Pune on four rows.

  3. Read the value operation

    Amount in Values with Sum adds 64, 110, 150 and 220. The specific cell should be 544.

  4. Validate the report scope

    Match that city result against the source and check the full total 2870. Test a different group if one result is inconsistent.

Lab 2 · Compare a growing Excel Table with a fixed range

Goal. Show why updating the report and including a row in its source are different actions. Use a scratch copy that preserves the original lab. Start with the named table and its existing report. Copy A1:C11 as values into a separate plain worksheet named FixedOrders. Keep the copy as an ordinary range. If it became a table on paste, create a clean worksheet and paste values only.

  1. Create a second report. From FixedOrders build the analogous City and Sum of Amount report using the explicit source range FixedOrders!A1:C11. Verify that this is a range, not the name of tblCityOrders. Choose a separate destination and identify the report clearly.
  2. Verify both baselines. Both should show 2870 and Pune 544 with no filters applied. This proves the different source types start with the same data.
  3. Append one controlled record separately to both inputs. Add BLK-1011, Pune and 40 in row 12 of the table sheet and the plain range sheet. Confirm the Excel Table actually grows to include row 12. Use its resize command or another supported method if needed. Leave the second source specification fixed for now.
  4. Use manual Refresh and compare. Refresh each summary on a supported edition, or check the updated report and confirm its values if your build already refreshed. The table-backed report should show 2910 total and Pune 584. The fixed report should still show 2870 and Pune 544 because the copied data row lies outside its source.
  5. Extend the plain report deliberately. On the supported report, use Change Data Source to set FixedOrders!A1:C12 and confirm the updated data. Refresh if needed. Expect the same 2910 and Pune 584. Show the source addresses alongside the two reports.
After row 12 with 40 rupees is appended, the fixed report stays 2870 until its source range is extended. The updated table-backed report includes row 12 and shows 2910.
The formula-free report still depends on a precisely defined range of source records.

Verify and recover. If the fixed report already shows 2910 in step four, inspect the selected source. A table or a dynamic reference may have captured the new row. If neither report shows the new amount, check the table boundary, report filter and actual update. Refresh does not automatically expand a literal fixed range. Restore the source and report scope after testing or close the scratch file.

Choose a destination that can accommodate a growing report

Use a new sheet for the first build

A PivotTable can change its height when a category appears or its width when you add another field. Placing it on a fresh worksheet gives you space to observe that change. You can keep the source in OrdersList and name the report Pivot_City so another person can identify their roles. Write any source checks outside the area the report may occupy. This reduces the chance that a longer result reaches manual notes or a second report.

On a supported edition, you can instead choose an existing worksheet and a valid starting cell. For practice this is useful when a person wants several related summaries in one place. Pick an empty output block with substantial space. Look at the layout before adding a new grouping, since changes can require more space. If Excel can't place or expand the result because something is already there, inspect the intended destination first. Keep the unrelated contents intact and move the summary to a more suitable space.

Match the goal if the menu names differ

On desktop Excel the blank creation tool usually starts from Insert and PivotTable, often with a source and destination dialog. Excel for the web can provide a side pane to select source and insertion location. Use the equivalent option for table or range data and check the visible address or name. These steps assume your edition can create a conventional PivotTable from a local worksheet. Microsoft documents separate platform procedures.

Field placement is explicit in this lesson. A recommended layout may preselect fields and operations. If your worksheet opens with a suggestion, inspect what it selected and recreate City in Rows and Sum of Amount in Values. A suggestion can form a valid report for another question. The baseline and its exact check help you decide whether the suggested grouping fits your purpose.

Read the parts of the field list

The upper field list contains the names in the source table. The layout areas express the organisation for the active PivotTable. If the field list is hidden, select a result cell and look for the field-list option in the PivotTable context or use the supported report menu. If you click a blank cell outside the PivotTable, some related options may disappear because you left the report context.

Drag City to Rows intentionally, then drag Amount to Values. A checked field may go to a suggested area based on its type. You can move it if the placement is different from the required report. The action changes report placement without affecting the underlying columns. Check the field list after changes and confirm it contains exactly the requested grouping and calculation.

Should you type the ₹544 result into a new PivotTable cell?

The report should calculate that figure from the source. Select the fields and check the operation. If you calculate it manually, use that as an independent check outside the report.

Run a small diagnostic when the result looks wrong

Compare the operation label and the underlying types

A report that shows Count of Amount is giving a count of populated values for that field, rather than the order amount total. Excel commonly uses Sum as the default for numeric data and Count for nonnumeric fields. Check the explicit summary operation and units. Then use Value Field Settings or the equivalent option to choose Sum for valid source amounts.

Try a controlled problem in a separate scratch copy. Replace the 1299 in C8 of OrdersList with the same digits stored as text. The orders are still present, and C8 can look nearly identical to before. The independent numeric count is 9 and the numeric total is 1571. A report expecting every amount to be a number now has a coverage issue. Inspect the candidate types, correct the known source from the practice fixture, and use the update control again. The original checks return to 10 and 2870.

Blank amounts and numeric zero need separate treatment. A confirmed zero has a real value that affects a numeric count. A missing amount has no measurement. If you intentionally set the known amount for one order to zero in a new practice case, label it and verify its numeric type. If the source is unresolved, keep the row present and show its missing coverage.

Diagnose extra and combined groups

Suppose a second label Nasik appears for one of the two Nashik orders. Under the raw field values the records can group separately. The correct precondition for a single Nashik amount is an approved reporting city field. A source map can maintain both the raw field and the approved label. Build the report from the approved field and check the former single-place total of 360.

If a city appears twice on a report, inspect adjacent fields and hierarchy. Some copies of a name could be legitimately nested under different parent groups or represent a source typo. A worksheet with both Platform and City in Rows may show the same city in more than one group by design. Understand the active placement before concluding that source values were duplicated. In our simple city-only report there is only one grouping field.

Record a broken condition with its own diagnostic test

Locate the cause of a difference before rebuilding
What you seeCheck firstExpected control
Field list lacks AmountSource boundary and column headerSource covers A:C with one usable header row
Values column displays 10Value field caption and summary methodCount of Order ID is 10, while Sum of Amount is 2870
Amount nearly doublesTotals or repeated input included as rowsSource contains ten real order rows and their typed amounts
City total unexpectedly splitsOriginal city names and the grouping hierarchyFour intended Pune records combine to 544
Source row is absent from the reportReport source boundary, update and active filtersA known append moves total from 2870 to 2910 when included

The order of these checks matters in real work. If the number column is missing from the actual source, no summary operation can add it. If the data are valid but the current display is Count, change the operation after confirming the intended measure. Start at the earliest stage you can verify and record which cause is supported.

What does changing a cell's number format establish?

It changes presentation. Use ISNUMBER, COUNT or another direct check to confirm the underlying value is numeric before choosing Sum.

Understand what changes after insertion

Separate source membership from report data state

Consider the two reports in Lab 2. They both display six cities and the same ₹2,870. If someone asks whether they will see an appended order next week, inspect the source definition. One report points to a named table with confirmed growth. Another points to a specific rectangular address. The filters and calculation can match while the defined source is different.

The effect is different if you edit an existing source cell. Try another scratch copy where you change C2 from 64 to 74 within both existing inputs instead of appending a row. After updating each report, total becomes 2880 and Pune becomes 554 under all statuses. Both sources already include that location. Restore 64 after checking. Comparing this test with a new external row helps you tell whether a report has a refresh problem or a membership problem.

Microsoft documents a version-dependent automatic update option for local PivotTables, currently available to Microsoft 365 Insider participants per the linked availability note. For supported local data the setting applies per source, and a shared source can carry an existing setting. Refreshing when the workbook opens is a separate option. Check your workbook's version and settings. Use manual Refresh and verify a known result in the broadly reproducible exercise.

Check for field changes before relying on old report layouts

If the latest export moves amounts to a new column or changes a field name, inspect the actual new source. Verify it still has the intended grain and measure. Changing the source reference can be appropriate for the simple fixed-range extension in this lab. A substantial change in the columns may make it clearer to build and independently verify a new PivotTable.

When you extend the range, keep the original header and include both the unchanging and newly intended records. Changing FixedOrders!A1:C11 to FixedOrders!A2:C12 would start at the first order instead of the header. That would misidentify the fields. Verify the selection begins with one header row and ends with the intended last record. Use obvious field labels and the count of expected records to detect an off-by-one selection.

Which change belongs to Change Data Source?

Use it to update a report's source definition when appropriate, such as including an extra row in a fixed range. Verify the recalculated values after the new scope is recognised.

Make the first summary reproducible for another reader

Label the amount, count and source consistently

Keep the operation explicit while debugging. Sum of Amount reminds a learner what the figures represent. Once you have verified the operation, use a supported settings option to give the entire value field a suitable number format. For rupee amounts with integer precision in this fixture, a grouped whole-number display is enough. Showing a currency symbol is optional if the caption already states rupees. Confirm that the format preserved the source data and displayed measure.

If you place Order ID in Values as a second report measure, inspect Count of Order ID. Count counts source field entries subject to scope. Because this fixture has one nonempty and unique ID per source order, the result equals ten orders. Use an independently verified row grain before writing this as Orders in the report. If the order appears on multiple line records, a count of populated IDs can be larger than a distinct-order count.

Compare Pune under both measurements. It has four IDs and ₹544. Solapur has one ID and ₹1,299. The city with the largest number of orders in this file is Pune, while the largest recorded amount among these cities is Solapur. These describe two different measures. State which one you are comparing when you send the report.

Prove the result by changing a single grouping

  1. Remove City from Rows. Keep Amount in Values with Sum. The single full-source amount remains 2870. The resulting report has no city groups.
  2. Return City to Rows. Recover the six individual amounts. Pune again appears with 544 and Nashik with 360.
  3. Move City to Columns in a scratch report. The comparison now spreads horizontally. For a fixed source with no filters, entries still refer to the same city totals. Return it to Rows after checking.
  4. Introduce a visible report filter. If you choose some cities and the total changes, inspect which items are included. Compare with their named source sums and clear the selection for the first lab's baseline.

Changing the location gives you a new view of existing data. The new result can answer a different question once filtering or grouping changes. Verify what changed under the active filter and whether your reader needs the grand amount for one included subset or the full recorded source.

Prepare a short note for the next analyst

Put a brief description outside the future report area or on a separate readme sheet. Note table name, expected source columns, one row per order and the value definition. Record the date or file version, plus the included status scope inherited from the chapter's starter data. The three-column copy uses all statuses. Use the full nine-column chapter dataset when a report needs status or platform filters.

Include two verification results, such as grand amount 2870 and Pune 544, so someone can identify the exact baseline. State the update test using BLK-1011, where a confirmed known append increases both the total and Pune by 40. Save the baseline and scratch variants separately if you keep both. A later reader can see whether a new input, a shifted scope or an accidental configuration explains a changed result.

Use a second set of controls to distinguish common failures

After the first lab works, save its known baseline and try one changed input at a time. Each test below describes the condition you changed, the source case you expect to see and the result that should stay steady. This makes it possible to diagnose a later report without memorising every menu.

Compare record counts with the count of fields

A1:C11 has eleven rows including the header and three columns. The exercise contains ten records, because a header is a field name rather than an observation. In a worksheet use =COUNTA(A2:A11) for the number of filled ID cells in this fixture. Check that every raw ID is a clearly filled literal. =COUNT(C2:C11) inspects the ten amounts, not the text IDs. Choosing the correct reference lets you explain separately that ten records were present and ten amounts were valid numbers.

As a controlled missing-key test, clear the copied value of Order ID for the 64 Pune amount in a new scratch sheet. Leave City and Amount intact. The source still contains the order measurement row. The ID count falls to nine, while numeric amount count remains ten and the all-row numerical sum remains 2870. A Count of Order ID would not establish that there were only nine recorded data rows. Ask whether incomplete-key rows should be held before using that derived count in a real report. Restore the original key immediately after the exercise.

Compare a growing group with a new item

The first append added Pune, a city that already had a report item. Another type of append creates a new item. Start again from the original ten rows in a separate scratch version. Add an approved Mumbai order, exercise ID AMN-1020, with amount 75 and City Mumbai. Confirm it belongs to the actual Excel Table and run the checked update. There should now be seven city groups. Pune remains 544. Mumbai appears with 75. Grand total becomes 2945 and the source contains eleven confirmed order IDs.

If the report has a filter specifying the original six cities, the new city can be excluded under that selected context even though it belongs to the table. Check the actual item selection and whether the practice report should include new items under the agreed scope. Clear the filter for the complete exercise control. A higher source count and an unchanged displayed total can therefore be a meaningful sign of report membership, rather than evidence of an invalid amount.

Check whether the right field is being summarised

Think of a separate copy of the source with a numeric Items Ordered column. A supervisor wants both item count and amount. A sum of this new field counts recorded items, whereas a Count of Order ID checks included identifiers and Sum of Amount produces rupees. Three numbers can be computed correctly for the same group and still have three different business meanings. If you add a quantity field to a future practice report, give it its own caption and unit.

Try a quick manual control with two synthetic orders under one city. The first has one item and ₹80. The second has five items and ₹180. There are two orders, six items and ₹260 in recorded amounts. Sum of Items Ordered is 6. Count of Order ID is 2. Sum of Amount is 260. These planned totals make a mistaken field placement easy to detect. Use this comparison when explaining why a count of worksheet rows is insufficient for a quantity report.

Verify a selected subset by its named records

Start with the city-only report and filter it to Pune and Nashik in the scratch version. The four Pune orders and two Nashik orders contribute ₹544 and ₹360, so the subtotal of the six selected records is ₹904. Use this exact subset to test whether the report is showing the intended geography. Read both city labels rather than relying on their current row numbers. This check addresses scope independently from the numeric field type.

Compare the same amount with a worksheet formula for each city or by reading the source rows. Then clear the city filter and expect ₹2,870 from the ten records. If only the selected measures were copied into a separate sheet, clearing a PivotTable filter would have a different effect. Verify whether your comparison uses an exported subset or the whole source before recording an exception.

In a final brief handoff include the actual filter state in the title. A number such as ₹904 can be correct and still need the names of the two selected cities to explain which records it covers.

Keep independent reports from obscuring one another

When comparing a fixed range and a growing Excel Table, give the two reports short review names and distinct worksheet destinations. For each one put the source table name or scope, measure and baseline count in a note outside the output region. If a later expansion needs space, move the report or choose another destination. Keeping each report outside the other report's result area makes change testing reversible.

When you finish each test, recover one known original check, such as ten records with 2870 total. That gives the next exercise an identical starting point. Keep unusual result variants in a separate scratch workbook if you are using them to explain setup mistakes to someone else. This prevents unfinished test data from being mistaken for the shared practice baseline.

Practise deliberate repairs

  1. Check the source header. On a plain scratch version introduce a title row above the three headers. Confirm which rectangle should be passed to PivotTable. Check. The range begins at the real header row. Keep the presentation title outside it.
  2. Distinguish source growth from a changed number. Compare changing a known amount inside the existing source with adding a new row beyond the boundary. Check. After refresh the inside change applies to both matching reports. The boundary test updates only the source that includes the new record.
  3. Verify currency labels after formatting. Apply a currency number format to the amount field, then inspect Pune. Check. The source and report still use 544 as the numeric amount under the same conditions. Check numeric type separately for new imports.
  4. Make the source city review independent. Use a temporary scratch city label variation and trace the group it creates. Check. Validate the source label and approved mapping. Restore your copy to the named base fixture.
Why include both a detail check and the grand total?

A report could balance in total while misassigning records to a group. Verify exact included source identities for one or more selected results as well as the whole amount.

Check your understanding

1. Which source labels become fields?

A. The selected header row's names. B. The separate workbook notes. C. The three largest numeric amounts.

Answer A. A conventional range or table source needs usable headings. Each one names a field the report can use.

2. Where should City go to create one result per city down the page?

A. Values. B. Rows. C. Hidden worksheet columns.

Answer B. The items belonging to City become row groups. Amount in Values supplies the numeric calculation for each.

3. What do you check if Values displays Count of Amount?

A. The chart subtitle only. B. Whether the worksheet address uses a dollar sign. C. The chosen summary operation and the source's numeric type.

Answer C. Verify the source amounts are usable numbers, then select Sum for a total.

4. Why can the fixed-range lab's refresh exclude BLK-1011?

A. Its source stops at row 11. B. Pune is not an approved city. C. The value has been multiplied before addition.

Answer A. The raw new order is below that rectangle. Refresh reads the specified source. Extending its scope allows the record to contribute.

5. What does a source that includes its own grand total risk?

A. Alphabetical sorting stops working. B. The previous total is added as though it were an actual source record. C. Creating a label always removes source values.

Answer B. Keep any presentation subtotal outside the dataset area. The report already calculates totals directly.

6. Which measure answers how many recorded orders contributed in this specific sample?

A. Max of Amount. B. The largest city total. C. Count of the populated unique order IDs in scope.

Answer C. The lesson has one nonempty unique order identifier per source row. Other sources can need a distinct-order measure.

Interview questions with worked answers

How do you create and test a PivotTable from a worksheet?

I identify a well-formed source with clear headers and a known row grain, verify the selected source and choose a separate output location. Then I place the grouping and measure fields, check their actual summary operation and compare one group and the grand total against the source.

When would you choose a fixed range?

A defined range can be appropriate for an intentionally fixed, static snapshot. A growing named Excel Table can simplify a recurring worksheet source. I check the actual source and whether a temporary append is included after updating.

How do you find a problem in a pivot that does not show a source field?

I inspect its true source rectangle or table, make sure the field belongs to that source and check the header structure. I verify that I selected an actual cell inside the report before looking for its field list.

What do you check if a new source row is missing?

I test whether the source includes the row, whether the report uses the latest data, and whether active filters exclude it. A correct refresh can still summarise a source that ends one row too early.

Why should an existing total be kept outside the source?

The source should contain the observations at its declared grain. An existing subtotal repeats parts of those observations. Including it in the PivotTable's source can count the same amounts a second time.

Quick recall cards

  • Headers

    One complete row of unique names defines the source fields.

  • Data grain

    Choose the rows you intend to count or sum. Keep display totals outside that scope.

  • Destination

    Allow room for the PivotTable to expand, especially when learning.

  • Grouping

    Place City in Rows and use a fitted calculation such as Sum of Amount.

  • Refresh

    Verify both the source boundary and current report output with a known test.

  • Check

    Compare one exact city group and the full total against source records.

Continue with the field areas lesson to build a complete city and platform report. The short guide to creating a PivotTable provides an additional quick reference.

Official Microsoft references

Continue practising: explore the existing Excel Task Hub for additional exercises.