Back to articles
Formulas
2025-01-297 min read
#formulas#functions

How to Simplify a Long Excel Formula with LET

Functions in this article

Jump to the reference pages for the Excel functions used below.

Browse library
Table of Contents

If your formula calculates the same sales total twice, LET lets you give that total a name and reuse it. You can then read the discount rule without picking through the same ranges again.

In this example, North's Tea sales total 200. A 10% discount applies when sales reach a threshold of 200, so both the original formula and its LET replacement return 20. That's the discount amount, not the amount left to pay.

LET is available in Excel for Microsoft 365 on Windows and Mac, Excel for the web, and Excel 2024 and 2021 on Windows and Mac, according to Microsoft's LET documentation. If you're using Excel 2019 or 2016, keep the original formula below.

Set up the sales and discount rule

You can download the example workbook to follow along. Its Sales sheet contains the data, both formulas, expected results, and the intermediate-total check; Notes describes the example. To build it yourself, use the same cells below.

On a sheet named Sales, paste this data into A1. The headers occupy A1:C1 and the seven records fill A2:C8.

Region	Product	Sales
North	Tea	120
South	Tea	90
North	Coffee	150
North	Accessories	40
South	Coffee	110
North	Tea	80
South	Tea	130
Text

Enter Threshold in K1 and 200 in K2. Enter Discount rate in L1 and 10% in L2. Use numeric sales amounts, and enter the percentage with its percent sign: 10% is stored as 0.1, whereas 10 would mean 1000%.

Next, set up a comparison area in E1:I5:

RowE: RegionF: ProductG: OriginalH: LETI: Expected
2NorthTea20
3SouthTea22
4NorthCoffee0
5WestTea0

The row numbers and column letters in this table show where to put the values; don't enter them as part of the headers. Leave G2:H5 empty for the formulas. Column I contains ordinary numbers you can compare with the calculated results.

Start with the repeated calculation

Enter this formula in G2, then copy it down through G5:

=IF(SUMIFS($C$2:$C$8,$A$2:$A$8,E2,$B$2:$B$8,F2)>=$K$2,SUMIFS($C$2:$C$8,$A$2:$A$8,E2,$B$2:$B$8,F2)*$L$2,0)
Formula

If your Excel uses semicolons between arguments, replace the argument-separating commas with semicolons.

The SUMIFS function adds the sales in C2:C8 where the region matches E2 and the product matches F2. For North and Tea, it finds 120 and 80, giving a total of 200. Our SUMIF and SUMIFS walkthrough explains those criteria in more detail.

The IF function checks whether that total is at least K2. If it is, the formula calculates the same total again and multiplies it by L2. Otherwise, it returns zero.

G2 should return 20: 200 meets the threshold, and 200 × 10% = 20. The formula works, but the long SUMIFS expression appears twice. If you need to change its criteria later, you have two places to edit.

Give the total a name with LET

Enter this version in H2 and copy it through H5:

=LET(total,SUMIFS($C$2:$C$8,$A$2:$A$8,E2,$B$2:$B$8,F2),IF(total>=$K$2,total*$L$2,0))
Formula

H2 should also return 20. Read the formula in three parts:

  1. total is the name you're defining.
  2. SUMIFS(...) supplies its value: 200 for this row.
  3. IF(total>=$K$2,total*$L$2,0) uses that value to return the discount amount.

The LET function keeps the discount rule unchanged. You have replaced the repeated calculation with a name that describes its result. Microsoft documents that LET can calculate a repeated expression once and reuse it; the benefit you can see here is having just one SUMIFS expression to maintain.

When you copy H2 down, E2 and F2 change to the next row's region and product. The dollar signs keep the source ranges, threshold in K2, and rate in L2 fixed. Each row calculates its own total.

LET formula selected in H2 with matching original, LET and expected results.
The original and LET formulas return the same four results: 20, 22, 0 and 0.

Return the intermediate total to check it

If a discount looks wrong, first check the sales total going into it. Enter this diagnostic version in J2:

=LET(total,SUMIFS($C$2:$C$8,$A$2:$A$8,E2,$B$2:$B$8,F2),total)
Formula

J2 should show 200. The final argument is now total, so the formula returns the subtotal instead of applying the discount rule. H2 still contains the complete formula and should show 20.

LET diagnostic formula selected in J2 returns the intermediate total of 200.
Return total as the final LET argument to inspect the intermediate value of 200.

This gives you a useful way to inspect a longer LET formula: temporarily return the named value you want to check. Keep a copy of the final calculation so you can put it back afterward.

Keep names local and meaningful

The name total belongs to the LET formula that defines it. Defining it in H2 doesn't create a workbook name that other cells can use. J2 works because it defines its own total.

Choose a name that describes the value and starts with a letter, such as total. Avoid cell addresses such as C2. Also avoid c: Microsoft flags a potential conflict with R1C1 reference syntax. Write the name without quotation marks.

Also keep the final result argument. LET needs a name, its value, and something to return; stopping after the name/value pair leaves the formula incomplete.

Check the threshold and no-match results

With K2 set to 200 and L2 to 10%, the expected results are:

CriteriaMatching salesOriginal in GLET in HWhy
North / Tea2002020Exactly meets the threshold
South / Tea2202222Exceeds the threshold
North / Coffee15000Below the threshold
West / Tea000No matching records

Change K2 to 201. North / Tea should now return 0 in both G2 and H2, while South / Tea stays at 22. This is why the comparison uses >=: a total equal to the threshold qualifies. Restore K2 to 200 afterward.

Change L2 to 0%, and every discount should become zero. Restore it to 10% to return to the original example.

LET doesn't clean the source data or handle calculation errors for you. A blank or text entry in the sales range contributes no numeric amount to SUMIFS; an error in a matching sales cell needs investigation. If a result shows an error, use the intermediate-total check and our guide to Excel formula errors to trace the cause.

These source ranges stop at row 8. If you add more sales below them, extend C2:C8, A2:A8, and B2:B8 to the same final row in each formula.

Use LET when a calculation needs a readable name inside one formula. If your next task is to save a calculation as a custom function you can call elsewhere in the workbook, creating a custom function with LAMBDA is the next step.

Enjoyed this guide?

Join our newsletter to get the latest Excel tips delivered to your inbox.

You can unsubscribe anytime. See our Privacy Policy.