عربي Add your service

Basic Excel formulas everyone should know, with examples

The basic Excel formulas everyone needs, from SUM and IF to SUMIFS, COUNTIFS and XLOOKUP, each with a short real example and the mistakes to avoid.

Basic Excel formulas everyone should know, with examples
6 min read Office tools

A dozen formulas cover most everyday work in Excel: SUM, AVERAGE, COUNT, MIN and MAX for quick totals, IF for decisions, SUMIFS and COUNTIFS for totals with conditions, XLOOKUP to fetch a value from another table, and IFERROR to tidy up errors. Every formula starts with an equals sign, and each one below has an example you can copy.

The examples use a simple sales sheet: dates in column A, the salesperson in B, the city in C and the amount in D, from row 2 to row 100. If Excel rejects a formula that looks right, check the separator: in some regional settings Excel expects a semicolon instead of a comma, as in =SUMIF(C2:C100;"Amman";D2:D100).

FormulaWhat it does
SUMAdds numbers
AVERAGEWorks out the average
COUNT / COUNTACounts cells with numbers / every cell that isn't empty
MIN / MAXSmallest / largest value
IFGives one result if a condition is true, another if not
SUMIF / SUMIFSAdds only the rows that meet one or more conditions
COUNTIF / COUNTIFSCounts only the rows that meet one or more conditions
XLOOKUP / VLOOKUPFinds a value in another table
IFERRORShows something else instead of an error
TODAYToday's date, updated every day

SUM, AVERAGE, COUNT, MIN and MAX: quick totals

  • SUM: =SUM(D2:D100) gives total sales. D2:D100 means every cell from D2 down to D100.
  • AVERAGE: =AVERAGE(D2:D100) gives the average sale. Empty cells are skipped, but zeros are counted, so they pull the average down.
  • COUNT and COUNTA: =COUNT(D2:D100) counts the cells that hold numbers, while =COUNTA(B2:B100) counts every cell that isn't empty, text included.
  • MIN and MAX: =MAX(D2:D100) finds the biggest sale and =MIN(D2:D100) the smallest.

For a quick look you don't even need a formula: select a range, and the status bar at the bottom of the window shows its sum, average and count. If a total looks too small, some numbers are probably stored as text and left out; cleaning up the file fixes that.

How does the IF formula work?

IF asks a yes-or-no question and gives an answer for each. To pay a 5% bonus on every sale of 500 or more: =IF(D2>=500,D2*5%,0). Text answers go between double quotes, as in =IF(D2>=500,"Target met",""), where the empty quotes leave the cell blank.

For two conditions, put AND or OR inside: =IF(AND(D2>=500,C2="Amman"),D2*5%,0) pays the bonus only on big sales in Amman. For several levels, Excel 2019 and Microsoft 365 have IFS, which is easier to read than one IF inside another: =IFS(D2>=1000,"A",D2>=500,"B",TRUE,"C").

SUMIFS and COUNTIFS: totals and counts with conditions

The formula =SUMIF(C2:C100,"Amman",D2:D100) adds the amounts only on rows where the city is Amman: where to look, what to look for, then what to add. SUMIFS takes as many conditions as you need, and the range to add comes first:

  • =SUMIFS(D2:D100,C2:C100,"Amman",B2:B100,"Sara"): Sara's sales in Amman.
  • =COUNTIF(C2:C100,"Amman"): how many sales were made in Amman.
  • =COUNTIFS(C2:C100,"Amman",D2:D100,">=500"): how many of them were 500 or more.

Comparisons go inside quotes, like ">=500". Better still, point to a cell: with the city typed in G2, =SUMIFS(D2:D100,C2:C100,G2) gives a new answer every time you change G2, without touching the formula. COUNTIF finds duplicates too: =COUNTIF($B$2:$B$100,B2) shows how many times each name appears, so anything above 1 is repeated.

XLOOKUP or VLOOKUP: find a value in another table

Say a sheet called Prices holds product codes in column A and prices in column B, and you need the price of the code in F2:

  • XLOOKUP (Microsoft 365, Excel 2021 and later): =XLOOKUP(F2,Prices!A:A,Prices!B:B,"Not found"). What to find, where to find it, what to bring back, and what to show if it is missing. It looks for an exact match by default and can bring back a column that comes before the one it searches.
  • VLOOKUP (every version): =VLOOKUP(F2,Prices!A:B,2,FALSE). The code must be in the first column of the range, and 2 means “bring back the second column”.

The classic VLOOKUP mistake is leaving out FALSE. Excel then looks for an approximate match and can return a wrong price without any warning.

When a lookup finds nothing it shows #N/A, and dividing by an empty cell shows #DIV/0!. IFERROR puts whatever you choose in place of any error: =IFERROR(VLOOKUP(F2,Prices!A:B,2,FALSE),"Not found") or =IFERROR(D2/E2,0). Add it only once the formula works, because it hides real mistakes too, such as a mistyped code.

TODAY and working with dates

Excel stores every date as a number of days, which is why dates can be added and subtracted. The ones you will use most:

  • =TODAY(): today's date, updated each time the file opens or recalculates. =NOW() adds the time.
  • =TODAY()-A2: how many days have passed since the date in A2. If the answer shows as a date, set the cell's format to Number.
  • =YEAR(A2), =MONTH(A2) and =DAY(A2): one part of the date.
  • =DATEDIF(A2,TODAY(),"y"): complete years between two dates, such as an age. Excel doesn't suggest this one as you type, but it works.

To type today's date as a fixed value that never changes, press Ctrl + ;.

What does $A$1 mean? Relative and absolute references

When you copy a formula down, Excel moves its references with it: =D2*E2 in row 2 becomes =D3*E3 in row 3. That is a relative reference, and usually it is what you want. But say the tax rate sits in one cell, H1. Copied down, =D2*H1 becomes =D3*H2 and points at an empty cell. Write =D2*$H$1 instead: the dollar signs fix the reference, so every row uses H1.

  • $H$1: column and row both fixed. This is an absolute reference.
  • H$1: the row stays 1 wherever you copy it, while the column can move.
  • $H1: the column stays H, while the row can move.

Instead of typing the dollar signs, click the reference in the formula and press F4 (Fn + F4 on some laptops) to cycle through the four forms.

Need a sheet built for you?

Some jobs take more of your time than they are worth: a monthly report that fills itself in, a dashboard, or an old file full of broken formulas. On fiverbox you can find sellers who build and repair spreadsheets, and every service costs $5, with paid extras when the job is bigger. The seller is paid only after delivering the work. When you order, send a sample of your data and say exactly what the result should show. If the numbers are going into a presentation, see how to make a professional presentation.

Questions people ask

Why does Excel show #NAME? in a cell?

Usually the function name is misspelled, text in the formula is missing its quotes, or the function doesn't exist in your version, as with XLOOKUP in Excel 2019 and earlier.

Why does my formula appear as text instead of a result?

The cell is probably formatted as Text, or there is a space before the equals sign. Set the format to General, then click in the cell, press F2 and Enter.

How do I see all the formulas in a sheet?

Press Ctrl + ` (the key above Tab on most keyboards), or choose Show Formulas on the Formulas tab. Press it again to go back to the results.

Do these formulas work in Google Sheets?

Yes. Every formula in this guide, XLOOKUP included, works the same way in Google Sheets.

Rather have it done for you?

Browse the services on offer, from $5.

Browse services

Read next

Sign in

Create account

Forgot password

Enter the email you registered with and we will send you a password reset link.