LAMBDA · Tax

Sales tax LAMBDA

xl.sales_tax rounds a price times a rate you supply to the cent. $120 at 6.25% is $7.50. $49 at 8.25% is $4.04.

Microsoft 365, Excel 2024, and Excel for the web. Excel 2021 does not have LAMBDA.

Syntax =xl.sales_tax(amount, rate)

xl.sales_tax
=LAMBDA(amount, rate,
  LET(
    tax, ROUND(amount * rate, 2),
    tax
  )
)

Arguments

NameRequiredWhat to pass
amountRequiredPrice before tax, in dollars.
rateRequiredThe rate for this line and this place. 6.25% and 0.0625 are the same input. The formula does not know the buyer's city.

Examples

$120 at the Massachusetts statewide rate

=xl.sales_tax(120, 6.25%)

Result $7.50

=ROUND(B1*B2,2)B3
Tax
AB
1Price120
2Rate6.25%
3Sales tax7.50
4Total127.50
A picture of the sheet, not a live calculator. B2 stores 6.25% as 0.0625. The total is the price plus the rounded tax.

xl.sales_tax is the tax line, not the total. $120 at 6.25% is exactly $7.50, so rounding does not move it. The case that shows the rounding is $49 at 8.25%: 49 × 0.0825 is 4.0425, and ROUND takes that to $4.04. The total is $53.04 only if you add the rounded tax to the price.

There is no national rate to bake in. Keep the rate in a cell. A lookup that misses should say so, not become 0%. Groceries, clothing, and medicine are taxed differently in many states, so the rate has to be the rate for that line.

Add it to the workbook

Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.sales_tax, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.sales_tax(...).

The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.

How it works

ROUND uses half away from zero. For a positive price that is the usual half-up rule. The LAMBDA returns only the tax. A companion total, if you want a second name xl.sales_total, is amount + ROUND(amount * rate, 2). Do not round amount * (1 + rate) and also round the tax. Those two answers differ by a cent on some tickets.

A rate table is a separate step. XLOOKUP of a state abbreviation against a Rates table can feed this function. The fourth argument of XLOOKUP should be a message, not zero.

Limits

This is not a determination of which rate applies, or whether you must collect it. A few states publish bracket charts instead of ordinary cent rounding. If you file in one of them, follow the chart. Alaska, Delaware, Montana, New Hampshire, and Oregon had no statewide general sales tax on the Tax Foundation table dated January 1, 2026. Local tax can still apply, and other excise taxes are a different question.