Creating a New Calculation in an Excel Pivot Table

Ever since I published the article on how to display both values and percentages in a pivot table & How to Get Running Totals in Pivot Tables, I am getting more and more emails asking about the other features and tricks within Pivot Tables in Microsoft Excel.

One such useful feature is the ability to add a new calculated field, which is not even present in the base data set, but can be derived from the existing fields.

We can call such a field as Adding a New Calculated Field in the Pivot Table. Once added, it is available to you in a pivot table as a regular field, and can be summed, counted, averaged, etc. with ease.

To Add a Calculated Field, go to the Pivot Table Options Menu, and Find the “Fields, Items & Sets” drop down menu in the ribbon.

Calculated Field Menu in Excel 2010, Excel 2013
Calculated Field Menu in Excel 2010, Excel 2013

Click and select the Calculated Field from the drop down menu.

Type a field name in the Name: field.

We will key in the formula in the next blank cell. Do note that Excel already provides you with a Zero there. You need to remove the Zero first. And then begin to type your formula.

Calculated Field in Excel Pivot Table
Calculated Field in Excel – Popup Screen

Want to Improve Your Excel Skills?

Learn the Key Features of Excel Quickly & Easily, by Joining the
Online Training on Basic / Intermediate Excel.

To Get Most out of Excel, Learn the  Pivot Table techniques in our
Pivot Table Masterclass Training
!


All the existing Fields are listed in the Field List below the formula.

Let’s say we have to calculate Bonus, which is 10% of the Sales Commission.

So the field Name we would give would be called Bonus.

The Formula would be =Sales Comm * 0.10

Click OK to close this popup menu.

You will now notice that a new field called Bonus is active in the Field List.

Double Click or Drag it to the Values Section of the Pivot Table Layout.

Voila! You have now created an new calculation called Bonus, based on existing values within the Pivot table, and it is now available for analysis in the Pivot Table.

You can use this simple technique to create as many pivot table fields, and enhance your analysis.

If you would like more such tips, you may subscribe to the ExcelChamp Excel Tips Newsletter or Excel Tips RSS Feed.

Cheers,
Vinai Prakash

Are you facing any problem in using Excel? Any Question?

You have come to the right place. Tell us your needs. We’ll be glad to help you!

PS: If you liked the tip, please do Like us, Stumble Upon on the Left Socials Bar, or Digg it!

How to Replace Blanks With Any Value or Zeros in Excel

This is a common problem. You import some text file, and half of it seems blank. The problem is that if it is showing blanks, you can’t sum the values.

To replace each blank with a zero is time consuming, boring and stupid. We want a fast method that works in just a few clicks, and saves us loads of time for our families 🙂

There are many ways to achieve this task of replacing Blank with Zeroes, or Replacing Blanks with Any Other Values in Excel.

Method 1: Use the GoTo Method to Find & Replace

Click on Home > Find & Select > GoTo Special. This will open up a new popup window.

Go To Special Popup in Excel
GoTo Special menu – Select Blanks

Choose Blanks Radio Button, and Click OK.

All the Blank Cells will get highlighted. Do not worry. Simply type a Zero or any other value that you want to put in the blank cells.

Do this in the currently active cell. Press

together.

Voila! The keyed in Values is showing in all the Blank Cells now.

Method 2: Use an IF condition

For example, if you want to selectively key in 0 for blanks, key in this formula below.=IF(A2=””,0,A2)

This formula checks if the cell A2 is blank or not. IF it is blank, it will replace it with a 0, or else it will not change it.

Once done, you can drag the formula to the selected cells. Works beautifully!

Want to Improve Your Excel Skills?

Learn the Key Features of Excel Quickly & Easily, by Joining the
Online Training on Basic / Intermediate Excel.

To Get Most out of Excel, Learn the  Pivot Table techniques in our
Pivot Table Masterclass Training
!


Method 3: Variation of the IF Method, using the ISBLANK function

Now we have an in-built function that can check if the cell ISBLANK or not.

=IF(ISBLANK(A2),0,A2)

Same Magic!

If you have any other favorite method, do share it with us below in the comments!

If you’d like to learn more Excel Shortcuts, Tips &  Tricks, here are some additional articles:

Questions About Any Feature in Excel?

If you have any questions regarding any feature in Excel, simply post a comment below and I’ll help you with it. All the best!

And Subscribe to our Weekly Excel Tips Newsletter, so we can send you more Short cuts & some Pivot Table Techniques by email. Only useful stuff, without the hype. And we won’t spam you. So don’t worry. Just subscribe!

Cheers,
Vinai Prakash, PMP, ITIL, GAP, Six Sigma
Founder of ExcelChamp.Net

Vinai conducts 1-2 day seminars and Training Sessions on Microsoft Excel all over the world, helping companies maximize their productivity in using Microsoft Excel. If you would like to find out more, simply contact us.

Are you facing any problem in using Excel? Any Question?

You have come to the right place. Tell us your needs. We’ll be glad to help you!

Do You Use These Features of Microsoft Excel?

Most people hardly use the most useful features available in Microsoft Excel. Many are just using Excel as a calculator to do basic calculations like adding or subtracting numbers. This is a gross under use of Excel’s vast potential and feature rich functionality.

Do a quick check, and see if you use these advanced features of Microsoft Excel in your day to day work to improve your productivity and efficiency.

  1. Finding the Top 10 Customers or Finding the Bottom 5 Performers in the organization
  2. Give Names to Range of Cells, and then use them in formulas for easy referencing and decoding – like =Salary – CPF + Allowance
  3. Exploit Pivot Tables to Summarize the data and slice & dice it in any way – like finding sales by product groups, or calculating productivity by department, or calculating sales by department by product by area.
  4. Write Macros to automate routine things that save you a huge amount of time – example creating different pivots, charts, tables, and doing complex calculations, or compiling the cost benefit ration, cash flow statement automatically.
  5. Highlight values that are above or below a certain threshold – like all sales above $25,000 to be highlighted, or all products with a net profit margin of less than 5% be highlighted.
  6. Sort the values in Ascending, Descending or any Customized sorting order – like sorting in order of Manufacturing, Accounts, Sales departments.
  7. Use advanced filtering conditions, and be able to filter data using multiple different criteria – like salary > 50,000 and sales <100,000 or Zone in East, West.
  8. Create fantastic charts that portray the given business situation perfectly. There are over 50 different types of charts to choose from, and each has its edge, advantages and a reason. Do you know when to use which type of chart – like two axis charts, stacked column and line charts, bubble charts, pie, slice of a pie etc.
  9. Create management dashboard that are dynamic, and provide a complete snapshot of the key business KPIs in the company – change the chart values at the click of a checkbox or change in a dropdown value
  10. Use Excel’s advanced What-If analysis to do projections for future, forecasting, trend analysis etc. with ease
  11. Use Lookup tables to find any value or corresponding value from a table using advanced functions and formulas – find values that in the left of the looked up value
  12. Protect certain cells from data entry, and hide the formulas from other cells. Ensure that only certain values are keyed in the cells to avoid data discrepancies.

Want to Improve Your Excel Skills?

Learn the Key Features of Excel Quickly & Easily, by Joining the
Online Training on Basic / Intermediate Excel.

To Get Most out of Excel, Learn the  Pivot Table techniques in our
Pivot Table Masterclass Training
!


This is just the tip of the iceberg… These are common things that can be done easily with Excel’s in-built features.

So how many of these did you know? And how many would you like to learn more about? Even if you learn one new trick in Excel, it will save you immense time and improve your productivity. Investing in Microsoft Excel Training bears fruit in no time, and is a no brainer.

Microsoft Excel is really extremely powerful. Each version of Microsoft Excel – be it Excel 2007, or Excel 2010 or Excel 2013, Excel 2016 or Office 365 adds more and more features to the already powerful dynamite of a package.

At ExcelChamp, we teach people how to leverage the maximum power out of Microsoft Excel in short training courses.

So what are you waiting for? If you would like to learn any one or more of such useful features of Microsoft Excel, just let us know. We provide online training through videos, which will show you each click, step by step, so you can master the new techniques easily, with exercises, and practical examples.

Go ahead, equip your team with the right skills. Get everyone on board to learn the basic and advanced features of Microsoft Excel, and Be Awesome in Excel!

Email to us to know more about Online Excel Training at ExcelChamp.Net.

Cheers,
VInai Prakash, PMP, ITIL, GAP, Six Sigma, Excel Guru

Are you facing any problem in using Excel? Any Question?

You have come to the right place. Tell us your needs. We’ll be glad to help you!

How To Count Cells With a Certain Value in Excel

There are several instances when you need to count the number of cells that contain a certain value.

For example, you want to:

  • Count if a product code is duplicated or not
  • Count the existence of a text string in a given range of cells

To do this, there are several different ways in Microsoft Excel.

Method 1: Use Sum & If Functions in Excel

=SUM( IF(range=”text”, 1, 0))

Note that this is an array formula, meaning that it must be keyed in a special way. Do not simply press Enter key to finish typing this formula. You must press CTRL + SHIFT + ENTER together.

Once you key in the array formula, it looks like below ( this formula searches for the value of 5 inn the cell ranging from A1 to C3. If it finds a 5, it counts a 1. All the counts are then Summed Up.)

=SUM( IF( A1:C3 = 5, 1, 0) )

Want to Improve Your Excel Skills?

Learn the Key Features of Excel Quickly & Easily, by Joining the
Online Training on Basic / Intermediate Excel.

To Get Most out of Excel, Learn the  Pivot Table techniques in our
Pivot Table Masterclass Training
!


Method 2: Use the inbuilt Countif Function of Excel

 =COUNTIF(A1:C3, “text”)

Note that this is a simple and straight forward way. It is not considered an Array function. Just key it in, and press the Enter key.

Voila, it shows you the correct count.

There you are! Two Simple ways to count the number of occurrences of a value in a range of cells in Excel.

These above 2 methods work in all versions of Excel, on the PC and on the Mac.

Hope you will benefit from them!

Cheers,
Vinai Prakash

Are you facing any problem in using Excel? Any Question?

You have come to the right place. Tell us your needs. We’ll be glad to help you!


Vinai conducts workshops to enable all Excel enthusiasts in learning simple tips, tricks, techniques in Excel. Join a 2 day workshop in Singapore, or email us the city where you want to have the workshop conducted. We can

How to Find the Second Highest Value in Excel (Every Case)

To find the second highest (second largest) value in Excel, use =LARGE(C2:C9,2). LARGE returns the Nth largest number in a range, so change the 2 to 3 for the third largest, 4 for the fourth, and so on. For the second smallest, use =SMALL(C2:C9,2).

That one formula covers most cases. But a few situations trip people up: duplicate values, finding the second largest per group, and getting the name next to the number. This guide handles each one, using the same small table throughout so you can follow along.

Quick Answers: Which Formula Do I Need?

I want… Formula (sample table below) Works in
Second largest value =LARGE(C2:C9,2) All versions
Second smallest value =SMALL(C2:C9,2) All versions
Second largest distinct value (skip ties) =LARGE(C2:C9,COUNTIF(C2:C9,MAX(C2:C9))+1) All versions
Second largest distinct value (shorter) =MAXIFS(C2:C9,C2:C9,"<"&MAX(C2:C9)) Excel 2019 and later
Second largest distinct value (dynamic arrays) =LARGE(UNIQUE(C2:C9),2) Microsoft 365, Excel 2021 and later
Second largest for one group =LARGE(IF(B2:B9="East",C2:C9),2) All versions (Ctrl+Shift+Enter in Excel 2019 and earlier)
Name next to the second largest =INDEX(A2:A9,MATCH(LARGE(C2:C9,2),C2:C9,0)) All versions
Top 3 rows with names =TAKE(SORTBY(A2:C9,C2:C9,-1),3) Microsoft 365, Excel 2024
Higher of two numbers =MAX(A1,B1) All versions

The Sample Data Used in This Guide

Every example below uses this sales list in cells A1:C9 (headers in row 1). Notice two things: the highest sale of 800 appears twice, and 650 appears twice. Both matter later.

A: Rep B: Region C: Sales
Asha East 500
Ben West 800
Chen East 800
Divya West 650
Elena East 720
Farid West 300
Gina East 650
Hao West 400

Sorted from highest to lowest, the sales are 800, 800, 720, 650, 650, 500, 400, 300.

Find the Second Largest Value with LARGE

MAX only returns the biggest number, so it cannot give you the runner-up. LARGE can. Its syntax is LARGE(array, k), where array is your range and k is the position, counting down from the largest.

=LARGE(C2:C9,2) returns 800.

Why 800 and not 720? Because 800 appears twice, LARGE counts it as 1st and 2nd. That is correct behaviour for ranking, but often not what people mean by “second highest”. The next sections fix that.

  • =LARGE(C2:C9,1) returns 800 (same as MAX).
  • =LARGE(C2:C9,3) returns 720.
  • =LARGE(C2:C9,5) returns 650.

You can also point at a range that spans several columns, such as =LARGE(B2:D20,2). LARGE looks at every number in the block.

Find the Second Smallest Value with SMALL

SMALL works the same way from the bottom. =SMALL(C2:C9,2) returns 400 (the smallest is 300). The same rule applies: if the lowest value is repeated, SMALL counts each copy as its own position.

Second Highest Value When There Are Duplicates

If you want the second highest distinct value, so the two 800s count as one, pick one of these. All three return 720 on the sample data.

Option 1: LARGE with COUNTIF (works in every version)

=LARGE(C2:C9,COUNTIF(C2:C9,MAX(C2:C9))+1)

COUNTIF counts how many times the maximum appears (2). Adding 1 skips past all of them, so LARGE jumps to position 3, which is 720. If the maximum appears only once, it simply returns the 2nd largest.

Option 2: MAXIFS (Excel 2019 and later)

=MAXIFS(C2:C9,C2:C9,"<"&MAX(C2:C9))

This asks for the biggest value that is smaller than the overall maximum. MAXIFS is not available in Excel 2016 or earlier.

Option 3: UNIQUE with LARGE (Microsoft 365 and Excel 2021 and later)

=LARGE(UNIQUE(C2:C9),2)

UNIQUE strips the duplicates first, leaving 500, 800, 650, 720, 300 and 400 (in their original order). LARGE then picks the 2nd largest of those, which is 720. It is the easiest to read, and you can change the 2 to get the third or fourth distinct value.

Second Largest Value for Each Group or Criteria

To find the second largest sale for the East region only (answer: 720; East has 500, 800, 720 and 650), use one of these.

Microsoft 365 and Excel 2021 and later

=LARGE(FILTER(C2:C9,B2:B9="East"),2)

FILTER keeps only the East sales, and LARGE picks the second biggest. For West, the same formula returns 650.

Older versions (array formula)

=LARGE(IF(B2:B9="East",C2:C9),2)

Press Ctrl+Shift+Enter to confirm it in Excel 2019 and earlier. IF returns FALSE for non-East rows, and LARGE ignores those.

Any version, no Ctrl+Shift+Enter

=AGGREGATE(14,6,C2:C9/(B2:B9="East"),2)

Function 14 is LARGE and option 6 ignores errors. Dividing by FALSE (zero) creates errors for the non-East rows, which AGGREGATE then skips. Microsoft’s documentation notes that functions 14 and 15 need the k argument.

Get the Name Next to the Second Largest Value

Usually you need the person or product, not just the number.

INDEX and MATCH (all versions)

=INDEX(A2:A9,MATCH(LARGE(C2:C9,3),C2:C9,0))

This returns Elena, the rep behind the second highest distinct sale (720). I used 3 here because the two 800s take positions 1 and 2. If you use LARGE(C2:C9,2) you get 800, and MATCH returns only the first 800, which is Ben. Chen is silently ignored.

XLOOKUP (Microsoft 365, Excel 2021 and later)

=XLOOKUP(LARGE(C2:C9,3),C2:C9,A2:A9)

Also returns Elena. XLOOKUP defaults to an exact match, so you do not need a match-type argument. It is not available in Excel 2016 or 2019.

Return every tied name with FILTER

=FILTER(A2:A9,C2:C9=LARGE(C2:C9,2))

Returns Ben and Chen, spilling into two cells, because both sold 800. Wrap it in TEXTJOIN(", ",TRUE,...) if you want them in a single cell.

Top N List with Names

=TAKE(SORTBY(A2:C9,C2:C9,-1),3)

SORTBY sorts the whole table by Sales from high to low, and TAKE keeps the first 3 rows. The result spills as: Ben, West, 800; Chen, East, 800; Elena, East, 720. Change the 3 to any number you like. TAKE is available in Microsoft 365 and Excel 2024, not Excel 2021 or earlier.

Top 3 in any version: type =LARGE($C$2:$C$9,ROWS($1:1)) in a cell and copy it down three rows. ROWS counts 1, 2, 3 as you fill down, so you get 800, 800, 720. Use SMALL the same way for the bottom 3.

If you still sort and copy values by hand for weekly reports, these formulas save that time, because they update themselves when the data changes. Our quick tip on re-sorting a list or table covers the manual route.

Ignore Zeros, Blanks and Errors

  • Blanks and text: LARGE and SMALL skip empty cells and text in a range, so you do not need to clean them out first. Numbers stored as text are also skipped, which is a common reason for a “wrong” answer.
  • Zeros: A zero is a real number, so SMALL will happily return it. To ignore zeros, use =SMALL(IF(C2:C9<>0,C2:C9),2) (Ctrl+Shift+Enter in Excel 2019 and earlier), or =AGGREGATE(15,6,C2:C9/(C2:C9<>0),2).
  • Errors: If one cell in the range shows #N/A or #DIV/0!, LARGE returns that error too. =AGGREGATE(14,6,C2:C9,2) ignores error values and returns the second largest of the rest.

Highlight the Second Largest Value

  1. Select A2:C9.
  2. Go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
  3. Enter =$C2=LARGE($C$2:$C$9,2) and pick a fill colour.

On the sample data, both the Ben and Chen rows are highlighted because both have 800. To highlight the top three instead, use Home > Conditional Formatting > Top/Bottom Rules > Top 10 Items and change 10 to 3.

Higher (or Lower) of Two Values

Not comparing a whole list, just two cells? Use =MAX(A1,B1) for the higher number and =MIN(A1,B1) for the lower one. No IF needed.

Common Mistakes and Errors

  • #NUM! error. Either k is 0 or negative, k is larger than the count of numbers in the range, or the range has no numbers. With only 8 numbers, =LARGE(C2:C9,9) returns #NUM!.
  • Getting the maximum twice. This is the duplicate issue above. If your answer looks the same as MAX, use one of the distinct-value formulas.
  • The wrong name returned. MATCH with 0 stops at the first match. For ties, use FILTER.
  • #SPILL! error. FILTER, UNIQUE and TAKE spill into neighbouring cells. Clear the cells in their way.
  • Numbers that are really text. If a value is left-aligned or has a green triangle, it is text and LARGE ignores it. Convert it to a number first.

The basic LARGE and SMALL formulas work the same way in Google Sheets and Excel for the web.

Frequently Asked Questions

How do I find the second highest value in Excel?

Use =LARGE(range,2). For example, =LARGE(C2:C9,2) returns the second largest number in C2:C9. LARGE counts duplicates as separate ranks, so if the top value appears twice you get that value again.

How do I find the second highest value if there are duplicates?

Use =LARGE(range,COUNTIF(range,MAX(range))+1), which works in every version. In Microsoft 365 or Excel 2021 and later you can use =LARGE(UNIQUE(range),2). In Excel 2019 and later, =MAXIFS(range,range,"<"&MAX(range)) also works.

How do I find the second highest value in a range for a specific category?

In Microsoft 365, use =LARGE(FILTER(values,categories="East"),2). In older versions, use =LARGE(IF(categories="East",values),2) with Ctrl+Shift+Enter, or =AGGREGATE(14,6,values/(categories="East"),2), which needs no special entry.

How do I return the name of the person with the second highest value?

Combine INDEX and MATCH: =INDEX(names,MATCH(LARGE(values,2),values,0)). In Microsoft 365 or Excel 2021 and later, =XLOOKUP(LARGE(values,2),values,names) does the same. If two people tie, only the first is returned, so use FILTER to list all of them.

What is the formula for the second smallest or second lowest value?

Use =SMALL(range,2). Change the 2 to find the third, fourth or any other lowest value.

How do I find the second max if there are blanks or errors in my data?

LARGE skips blanks and text automatically. For errors, use =AGGREGATE(14,6,range,2), where 14 means LARGE and 6 means ignore errors.

Keep Learning

Learn the lookup functions used above in Master These Excel Lookup Functions To Save Time, and see where LARGE fits among the essentials in Top 12 Most Important Excel Functions. If duplicates are your real problem, read How to Find and Remove Duplicates in Excel Quickly. To summarise whole tables without formulas, try How To Summarize Data in Excel: Top 10 Ways.

Want to build these skills faster? The Excel for Beginners video course takes you from the basics to confident formula work, at your own pace.