Best Click Rate Day and Peak ISO Week in an Ad Log Using Pivots
SQL & DataModel answerLast updated
Use Excel helper columns and PivotTables to find the day with the highest clicks per watch-minute and the ISO week with the most watch time, with deterministic tie-breaks.
You have a flat export of ad viewing activity with these columns:
Date: an Excel date with no time zoneUserIDAdIDWatchSeconds: integer, 0 or moreClicks: integer, 0 or more
You may use only Excel (no Power Query). Describe precisely how you would do the following.
-
Helper columns. Add these to the source data:
Weekday = WEEKDAY([@Date], 2)(Monday = 1)ISOWeek = ISOWEEKNUM([@Date])ISOYear = YEAR([@Date] + 4 - WEEKDAY([@Date], 2))
Explain why
ISOYearis needed around the turn of the year. -
Best click-rate day. Build a PivotTable that finds the single calendar date with the highest clicks per watch-minute, defined as
(SUM Clicks) / (SUM WatchSeconds / 60). Use a PivotTable Calculated Field and give the exact formula string. If dates tie, the earliest date wins. Explain how you would enforce that deterministically. -
Peak week. Build a second PivotTable that totals
WatchSecondsbyISOYearandISOWeekand returns the week with the largest total. If weeks tie, the later week (by ISOYear, then ISOWeek) wins. -
Pitfalls. Give two ways that using
WEEKNUM/WEEKDAYinstead of ISO logic can yield wrong answers (for example weeks that straddle Dec/Jan, or locale-dependent week starts).
Report the two answers, the Top Date and the Top ISO Week (formatted ISOYear-W##), and lay out step by step the exact clicks-per-minute and total-WatchSeconds computations you would perform in the PivotTables.
Hints
Hint 1
A ratio of totals is not the same as the average of per-row ratios. Check how a Calculated Field aggregates before it evaluates its formula.
Hint 2
An ISO week belongs to the year containing its Thursday. Look at what adding 4 minus the Monday-based weekday does to any date.
Hint 3
Do not trust pivot sort order to break ties. Read the pivot output with a formula (MAX, then MIN or MAX over the matching rows), and round the ratio first to avoid floating-point noise.
Hint 4
Encode ISOYear and ISOWeek into one numeric key such as ISOYear*100+ISOWeek so that the 'later week' tie-break becomes a plain MAX.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What this task is really testing
- A ratio of sums differs from an average of ratios.
- ISO week and ISO year rules matter at year boundaries.
- Excel results must be made deterministic when ties occur.
The actual answers depend on the data. A strong response gives the exact mechanics that produce them.
1. Helper columns
Convert the range to a Table (Ctrl+T, named Ads) and add:
| Column | Formula | Purpose |
|---|---|---|
| DateKey | =INT([@Date]) | Removes any hidden time fraction so one day is one pivot item |
| Weekday | =WEEKDAY([@Date],2) | Monday=1 ... Sunday=7 |
| ISOWeek | =ISOWEEKNUM([@Date]) | ISO 8601 week, 1 to 53 |
| ISOYear | =YEAR([@Date]+4-WEEKDAY([@Date],2)) | Year that owns the ISO week |
| YearWeek | =[@ISOYear]*100+[@ISOWeek] | Single sortable key, e.g. 202053 |
Why ISOYear is required. An ISO week runs Monday to Sunday and belongs to the year containing its Thursday. Date + 4 - WEEKDAY(Date,2) shifts any date to the Thursday of its week (Monday +3, Sunday -3), and YEAR of that Thursday is the owning year.
- Friday 2021-01-01 maps to Thursday 2020-12-31, so ISOYear is 2020 and the week is 53. Plain
YEARwould produce "2021-W53", a nonexistent week that splits the real 2020-W53. - Monday 2024-12-30 maps to Thursday 2025-01-02, so it is 2025-W01. Plain
YEARwould give "2024-W01" and merge late-December days into the wrong week.
Pairing ISOWEEKNUM with calendar YEAR silently corrupts weekly totals.
2. Top date by clicks per watch-minute
Pivot setup
- Insert a PivotTable from
Adswith DateKey in Rows. If Excel auto-groups dates into years/months, right-click and Ungroup. - Use Tabular layout and turn off Grand Totals so they never enter the max formula.
- Add Sum of Clicks and Sum of WatchSeconds as audit columns.
- Add a Calculated Field named
ClicksPerMin:
= Clicks / (WatchSeconds / 60)
A Calculated Field operates on the summed fields in each row context, so for each date it yields (Σ Clicks) / (Σ WatchSeconds / 60). It never averages row-level ratios.
Zero-watch days would give #DIV/0!. A guarded version is:
= IF(WatchSeconds = 0, 0, Clicks / (WatchSeconds / 60))
State your assumption: days with no watch time are ineligible rather than having an infinite rate.
Deterministic earliest-date tie-break. Pivot sorting uses one key, and the order among equal values is not guaranteed, so compute the answer from the pivot output. With dates in A5:A400 and the ratio in D5:D400:
=LET(d, A5:A400, r, ROUND(D5:D400, 9),
m, MAX(r),
MIN(FILTER(d, r = m)))
Format the cell as a date. Rounding matters because mathematically equal rates (2 clicks over 360 s versus 1 click over 180 s) can differ in the last floating-point bit and turn a true tie into a false win.
Without dynamic arrays, add a helper column E = ROUND(D5,9) beside the pivot and use:
=MINIFS(A5:A400, E5:E400, MAX(E5:E400))
Steps to state
- Group by DateKey.
- Sum Clicks and sum WatchSeconds per date.
- Compute ΣClicks / (ΣWatchSeconds / 60).
- Round to 9 decimals and take the maximum.
- Return the minimum date among those equal to the maximum.
3. Top ISO week by total WatchSeconds
Pivot setup
- New PivotTable from
Ads, Rows: ISOYear then ISOWeek (or the singleYearWeekkey). - Values: Sum of WatchSeconds (verify it is not Count).
- Design: Tabular form, Repeat All Item Labels, Subtotals off, Grand Totals off.
Deterministic latest-week tie-break. With ISOYear in A, ISOWeek in B, and the sum in C:
=LET(y, A5:A200, w, B5:B200, s, C5:C200,
k, y*100 + w,
best, MAX(FILTER(k, s = MAX(s))),
INT(best/100) & "-W" & TEXT(MOD(best,100), "00"))
The key y*100+w orders weeks chronologically, so MAX over the tied weeks picks the latest. TEXT(...,"00") pads the week number, giving 2020-W53 or 2025-W01. WatchSeconds are integers, so ties are exact and no rounding is needed.
Steps
- Bucket rows by (ISOYear, ISOWeek).
- Sum WatchSeconds per bucket.
- Find the maximum sum.
- Among buckets at the maximum, take the largest key.
- Format as
ISOYear-W##.
4. Pitfalls with WEEKNUM / WEEKDAY
- Year-boundary misassignment.
WEEKNUM(date)defaults to return type 1: weeks start on Sunday and week 1 contains January 1. So Jan 1 is always week 1, even where ISO places it in week 52 or 53 of the previous year, and late-December dates can be ISO week 1 of the next year. Mixing any week number with calendarYEARproduces split or merged weeks exactly where the maximum might sit.WEEKNUM(date,21)matches ISO numbering but still needs ISOYear. - Week-start conventions.
WEEKDAY(date)with no second argument returns Sunday=1. That shifts every weekday label and breaks the ISOYear formula, which assumes Monday=1. US and European templates often assume different week starts. Always pass return type 2 or useISOWEEKNUM.
Other issues worth mentioning:
- Text dates parsed by locale (03/04/2024 as DD/MM versus MM/DD) silently move rows.
- Hidden time fractions split a day into many pivot items;
INTfixes this. - The 1904 date system shifts all dates by four years and a day.
Final answers (structure)
- Top Date: the minimum DateKey whose rounded ΣClicks / (ΣWatchSeconds / 60) equals the maximum.
- Top ISO Week: the latest
ISOYear-W##whose ΣWatchSeconds equals the maximum.
Common mistakes
- Averaging per-row click rates, or using "Average of" in Values, instead of a ratio of sums.
- Using
YEAR(Date)with ISO weeks. - Leaving Grand Total rows inside the MAX/MIN ranges.
- Leaving automatic date grouping on.
- Relying on pivot sort order to resolve ties.