Level 3CapstonesProject, 12 min

Capstone: an automated weekly report

The task

Sales and marketing log every day's results on the Log tab. Build a Report tab that always shows the latest week, with no dates typed by hand: it finds the week, summarizes it, totals it, compares it with last week and writes its own headline. Add an Apps Script trigger to email it every Monday and nobody has to touch it again.
  1. Find the latest weekOn Report, in B1, find the Monday of the week holding the latest date in the log. Name the latest date with LET, then step back to Monday: =LET(last, MAX(Log!A2:A15), last - WEEKDAY(last, 2) + 1).
  2. This week by channelIn A3, FILTER the log to rows on or after B1, then QUERY the result by channel. Filtered data has no header row, so name columns Col1, Col2... and pass 0 as the third input: =QUERY(FILTER(Log!A2:E15, Log!A2:A15>=B1), "select Col2, sum(Col3), sum(Col5) group by Col2 order by sum(Col5) desc label Col2 'Channel', sum(Col3) 'Leads', sum(Col5) 'Revenue'", 0)
  3. A total row with HSTACKIn A8, right under the table, build the total row in one formula: the word Total, this week's leads and this week's revenue, side by side with HSTACK. Use SUMIFS on the log with ">="&B1 as the date test.
  4. Week over weekIn B10, compare this week's revenue with last week's (the seven days before B1): this week divided by last week, minus 1.
  5. A headline that writes itselfIn B12, join the pieces into one sentence with & and TEXT, so it reads exactly: Week of Oct 19: $21,650 revenue, 30% vs last week

The data, 2 tabs

The starting sheet. Cells outlined in green are where your formulas go.

Report tab
AB
1Week starting
2
3
4
5
6
7
8
9
10vs last week
11
12Headline
13
14
Log tab
ABCDE
1DateChannelLeadsDealsRevenue
2Oct 6Paid Search425$6,200
3Oct 7Paid Social353$3,900
4Oct 8Email184$4,100
5Oct 9Referral92$3,300
6Oct 13Paid Search394$5,400
7Oct 14Paid Social415$5,800
8Oct 14Email213$3,600
9Oct 16Referral71$1,900
10Oct 20Paid Search476$7,100
11Oct 21Paid Social332$2,700
12Oct 21Email255$5,300
13Oct 22Paid Search121$1,450
14Oct 23Referral113$4,200
15Oct 23Email61$900