Excel extras
Which campaigns deserve the budget?
You have built the sales report. Now add marketing campaigns and examine the margin remaining after advertising spend. All records are synthetic. This optional challenge is for workshop participants and requires no newsletter subscription.
A new export to connect
Use Vendite.xlsx, Magazzino.xlsx and Anagrafica.xlsx from Lesson 1. Marketing.xlsx contains only data tables, as a system export would:
- Campagne: 6 entries with stable IDs, channel, dates and attribution model. Social and Google each have two half-year campaigns; two organic entries reconcile the remaining sales.
- Spesa Mensile: 36 rows, one per campaign and active month. Spend is simulated actual advertising cost in euros, not a budget to allocate.
- Attribuzione Ordini: 100 rows, one per order, with campaign and customer IDs. An order has one attribution even when it contains multiple products.
Keys to use
ID Ordine links sales lines to Attribuzione Ordini. ID Campagna links attribution, campaigns and monthly spend. Codice Cliente retains the C… and A… codes from Lesson 1: names and email addresses are not keys.
The existing Campagna field in Vendite identifies only the channel (social, google, organico). Use ID Campagna to distinguish campaigns in this exercise. Monthly amounts use the composite key ID Campagna + Mese; Mese is a date representing the first day of the month.
Try it yourself
- Import the three marketing tables with Power Query. Join sales to order attribution on ID Ordine, then to campaign details on ID Campagna. Retain all 140 sales lines.
- Reuse Lesson 1 net revenue, cost of goods sold and gross margin. Delivered lines contribute; fully refunded returns and cancellations contribute zero net revenue and cost of goods sold.
- Group sales by campaign and month, summing revenue and margin. Also count distinct delivered orders and distinct purchasing customers, rather than product lines.
- Start from the 36 monthly spend rows and join aggregated sales on campaign ID and month. Keep months without sales: their costs still exist. After verifying the join, missing revenue for a no-sales month can be treated as zero.
- Calculate margin after advertising = gross margin − advertising spend. For paid campaigns calculate ROAS = attributed revenue / spend. Organic spend is zero: ROAS is not applicable, rather than zero or infinity.
- Compare campaigns and channels. Write three lines for a manager: what appears to work, what you would reduce and which information is missing before deciding.
I need a hint
Use Left Outer to retain sales. Verify unique order IDs in attribution and unique campaign IDs in campaign details. Derive the month with Date → Month → Start of Month, and use Group By for sums.
Avoid summing spend after copying it onto every sales line. If a month costs €95 and has four product lines, the cost remains €95 rather than €380. Aggregate sales before joining costs.
To count orders, filter delivered records, retain campaign, month and order ID, remove duplicates on those fields and count by group. Repeat with Codice Cliente for customers. Recalculate total distinct customers over the whole period; monthly and campaign customer counts are not additive.
Check your result
Before joins: 140 sales lines, 100 orders, 6 campaigns and 36 spend rows. The 100 attribution rows cover all orders; 80 orders are delivered. Customers with at least one delivered order: 51.
Expected totals: net revenue 15,322.50 €; gross margin 8,686.34 €; advertising spend 2,880.00 €; margin after advertising 5,806.34 €.
| Campaign | Revenue € | Spend € | Margin after advertising € |
|---|---|---|---|
| MKT26-ORG-H1 | 3,040.50 € | 0.00 € | 1,729.09 € |
| MKT26-ORG-H2 | 2,854.00 € | 0.00 € | 1,614.02 € |
| MKT26-SEA-H1 | 929.50 € | 870.00 € | -334.73 € |
| MKT26-SEA-H2 | 2,290.00 € | 870.00 € | 452.11 € |
| MKT26-SOC-H1 | 3,620.00 € | 570.00 € | 1,433.62 € |
| MKT26-SOC-H2 | 2,588.50 € | 570.00 € | 912.23 € |
What can you conclude?
Last-touch attribution is simulated and assigns each order to one campaign. It describes an association; it does not establish that advertising caused the sale. Organic entries provide a comparison rather than free advertising campaigns.
Margin after advertising is not net profit: other business costs are missing. Do not call spend divided by all buyers CAC; the dataset does not establish who is newly acquired. A real decision would need acquisition and exposure data and a credible comparison without the campaign.