Calculate Per-Appointment Discounts and Subtotals in Microsoft Access
Question details
The user needs to calculate conditional discounts for individual appointments in Microsoft Access before grouping the costs to ensure accurate subtotals per owner.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Generating a report or query where an owner has multiple appointments, and a conditional discount must apply to specific appointment costs individually rather than to the combined total.
- Observed behavior
- Access groups the total costs together before applying the conditional discount, resulting in an inaccurate subtotal for owners with multiple appointments.
Open your Microsoft Access database and ensure you have access to the query design view for the tables containing your appointment and cost data.
Calculate Discounts at the Row Level Before Grouping
Apply the IIf function directly to individual records in your query to calculate the discount per appointment before summarizing the results.
When you create a query involving multiple appointments for a single owner, Access may aggregate the total cost before applying conditional discounts if the formulas are placed in the totals row. To fix this, you must calculate the discount as a new field at the row level first.
Using the IIf function allows you to evaluate each cost individually. Once the individual discounts and discounted costs are calculated, you can wrap the query or use the Totals feature to group the results by the Owner ID accurately.
In Microsoft Access, open your existing query in Design View or create a new query selecting your Appointments, Owners, and Treatment Costs tables.
In an empty field column, enter the expression for the discount. For example: Discount: IIf([Cost] > 20, [Cost] * 0.2, 0).
In the next empty column, enter the expression for the subtotal per appointment: DiscountedCost: IIf([Cost] > 20, [Cost] * 0.8, [Cost]).
Click the Totals button on the ribbon. Set the Total row for your ID field to 'Group By', and set the Total row for your newly created Discount and DiscountedCost fields to 'Sum'.
Click Run to view the results. Individual appointment costs that meet the criteria will be discounted appropriately before being summed together for the final subtotal.

Need a Lightweight Alternative for Data Management? Try WPS Office
While WPS Office does not include a direct clone of Microsoft Access, WPS Spreadsheet provides powerful data analysis, pivot tables, and conditional logic (like IF functions) to handle complex subtotals and discounts effortlessly. It is highly compatible with Microsoft Excel formats, making it a perfect free alternative for your daily data processing needs.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package.
- 2. Install the suite: Run the installer and follow the on-screen instructions to set up WPS Office on your computer.
- 3. Open WPS Spreadsheet: Launch the application and open your exported data to easily calculate conditional discounts using familiar IF functions.

Frequently Asked Questions
Why is my Access query grouping costs before applying the discount?
This happens if the discount calculation is placed in a field where the Totals row is set to 'Expression' based on already summed fields. You must calculate the discount at the row level first by applying the IIf function directly to the raw Cost field before applying the 'Sum' total.
How do I use the IIf function in Microsoft Access for conditional discounts?
You can use the syntax IIf(condition, true_part, false_part). For example, IIf([Cost]>20, [Cost]*0.2, 0) checks if the cost is over 20; if true, it calculates a 20% discount; if false, the discount is zero.
Can I summarize these calculated query fields in a report?
Yes. Once you calculate the per-appointment discounts in a query, you can use that query as the Record Source for your report. You can then add grouping and sorting in the report design view to show accurate subtotals per Owner ID.




