How to apply a wholesale discount automatically in a spreadsheet

· 6 min read

A wholesale discount that depends on someone's memory gets applied unevenly. One person gives Cafe Lotus 15%, another gives 10% because that is what it used to be, and a third forgets it on a busy day. The fix is to stop typing discounts. Write down once who is a wholesale customer and what wholesale customers get, and let every sales row look both up.

The steps are for Google Sheets. The example is a shop selling mugs, plates and teapots, with no currency assumed, and the rates are examples only.

Record each customer's type once

Add a tab called Customers with Customer in column A and Customer type in column B:

Customer Customer type
Cafe Lotus Wholesale
Meena Home Retail
Sri Stores Wholesale
Hill Stores Distributor

One row per customer. This is the only place that says who gets wholesale terms, so a customer cannot be wholesale on Monday's order and retail on Friday's.

Keep the rates in a small table

Add a tab called Discounts. Type Customer type in A1 and Discount in B1, then:

Customer type Discount
Retail 0%
Wholesale 15%
Distributor 25%

Type each rate with its percent sign. A third or fourth type is one more row here, with no formula to edit. An IF that checks for the word Wholesale handles two types and grows with every type you add.

Now make column B of Customers a dropdown that reads this table, so a type can only be one that has a rate:

  1. On the Customers tab, select B2 down to B200.
  2. Choose Data > Data validation > Add rule.
  3. Under Criteria pick Dropdown from a range and enter Discounts!A2:A. Click Done.

Google's page on dropdown lists says an entry that is not on the list is rejected by default. Our guide to a dropdown for order status explains the other options.

Look up the type, then the rate

Add a tab called Sales with these headers in row 1:

A B C D E F G
Customer Product Quantity List price Customer type Discount Line total

Columns A to D are typed. Make column A a dropdown from the range Customers!A2:A, using the same three steps. Columns E to G are formulas. Put these in E2, F2 and G2:

Customer type =IF(A2="", "", XLOOKUP(A2, Customers!A:A, Customers!B:B, "Not on Customers"))

Discount =IF(A2="", "", XLOOKUP(E2, Discounts!A:A, Discounts!B:B))

Line total =IF(A2="", "", ROUND(C2*D2*(1-F2), 2))

Fill all three down to row 200. The IF(A2="", "", ...) part keeps a row blank until a customer is chosen.

XLOOKUP finds a value in one column and returns the cell from the same row of another. The first formula returns the customer's type, and the second returns that type's rate. Format column F as a percent with Format > Number > Percent.

The list price is typed here to keep the example short. To look it up from a price list as well, see how to build a quote calculator.

Add quantity breaks with a second table

Many wholesalers also give more off for a larger quantity. On the Discounts tab, type Quantity from in D1 and Extra discount in E1, then:

Quantity from Extra discount
0 0%
50 5%
200 8%

Change the Discount formula in F2 to this and fill it down again:

=IF(A2="", "", XLOOKUP(E2, Discounts!A:A, Discounts!B:B) + XLOOKUP(C2, Discounts!$D$2:$D$4, Discounts!$E$2:$E$4, 0, -1))

The second XLOOKUP has two more parts. The -1 is the match mode. Google's page describes it as an exact match or the next value that is lesser than the search key. So a quantity of 60 is not in the table, and the formula settles on 50 and returns 5%. The 0 before it is what to return if nothing matches.

Three details matter:

  • Keep the row that starts at 0. It is the row every small quantity lands on.
  • The $ signs stop the range from sliding down as you fill the formula.
  • If you add a fourth break, change both ranges to end at row 5.

This formula adds the two rates together. Applying one after the other gives a slightly smaller discount, and the quote calculator guide shows the difference. Pick one rule and keep to it.

Check it against five rows

Type columns A to D and the rest should appear:

Customer Product Quantity List price Customer type Discount Line total
Cafe Lotus Dinner plate 60 449 Wholesale 20% 21,552.00
Meena Home Teapot 2 999 Retail 0% 1,998.00
Sri Stores Blue mug 50 299 Wholesale 20% 11,960.00
Hill Stores Blue mug 200 299 Distributor 33% 40,066.00
Green Leaf Deli Teapot 10 999 Not on Customers #N/A #N/A

Work the first one by hand. 60 plates at 449 is 26,940. Cafe Lotus is Wholesale, which is 15%, and 60 falls in the break that starts at 50, which is 5% more. 20% of 26,940 is 5,388, so the line total is 21,552.

The other rows test the edges. Sri Stores orders exactly 50, and the 5% applies, because the break starts at 50 and not above it. Hill Stores gets 25% as a distributor plus 8% for 200 units: 59,800 less 33% is 40,066.

The last row is typed in by hand to show what an unknown name does. Green Leaf Deli is not on the Customers tab, so the type reads Not on Customers, no rate is found for that text, and the total is an error. That is deliberate. A sale to a customer nobody has classified should stop you, not pass quietly at some default rate. If you would sooner treat unknown customers as retail, change "Not on Customers" to "Retail" in the first formula.

Fix the numbers once a sale is invoiced

Every row reads the Customers and Discounts tabs live, including last month's rows. Move Meena Home from Retail to Wholesale today, and her earlier row of two teapots drops from 1,998.00 to 1,698.30, although she paid 1,998.

So when a sale is invoiced, fix its numbers:

  1. Select E to G on that row and copy.
  2. With the same cells selected, choose Edit > Paste special > Paste values only. Google's page on copy and paste says this pastes only the text from the copied cells.

The row now holds plain values that a later change of type or rate cannot move.

Fix a discount that looks wrong

  • Discount shows #N/A. The customer's type has no row on the Discounts tab, or the customer is not on the Customers tab. Check column E on that row first.
  • The line total is negative. A rate was typed as 15 without the percent sign, which is 1,500%.
  • The line total shows #VALUE!. The quantity or price was typed as text, such as "200 pcs". Type the number alone.

Where BoltSheets fits

Everything above works in a plain Google Sheet. The BoltSheets quote calculator template uses a simpler rule: Customer type is a dropdown chosen on each quote, with Retail and Wholesale only, and its Settings tab holds one rate for each plus a single bulk threshold. It does not look the type up from a customer list and has no table of quantity breaks, so those are yours to add. In the demo you can ask in words for a discount rate to be changed. The change is shown as a preview and written only when a person confirms it, and formula cells are never written to. BoltSheets is in early access and works with Google Sheets only.

Common questions

Can I use VLOOKUP for the quantity breaks instead of XLOOKUP?

Yes. =VLOOKUP(C2, Discounts!$D$2:$E$4, 2, TRUE) returns the same rate. Google's VLOOKUP page says to sort the first column in ascending order before using an approximate match, and that a quantity smaller than the smallest value returns #N/A, which is another reason to keep the row that starts at 0.

How do I give one customer a rate of their own?

Add a row to the rate table with a new type, for example Key account at 18%, and choose that type for the customer on the Customers tab. No formula changes. This is safer than typing over the Discount cell on a sales row, because the next person to fill the formula down would erase it.

How do I show the discounted unit price on each row?

Add a column with =IF(A2="", "", ROUND(D2*(1-F2), 2)). Be aware that quantity times a rounded unit price can differ by a few hundredths from the line total worked out in one step. Decide which of the two figures your invoice shows and use that one everywhere.

What if wholesale pricing should only apply above a minimum quantity?

Wrap the type lookup in an IF. Put the minimum in a cell such as Discounts!H2, then replace the first XLOOKUP in the Discount formula with IF(C2>=Discounts!$H$2, XLOOKUP(E2, Discounts!A:A, Discounts!B:B), 0). Smaller rows then get no type discount.