Build an L7 Engagement Histogram for Facebook App Users

Last updated: November 29, 2026

Quick Overview

Using a daily activity table, compute for a given date how many users were active on exactly 1, 2, ... 7 of the trailing seven days (the L7 distribution), among users active at least once in that window.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Using a daily activity table, compute for a given date how many users were active on exactly 1, 2, ... 7 of the trailing seven days (the L7 distribution), among users active at least once in that window.

L7 and L28 histograms are a classic Meta engagement view: they show whether a product has a core of daily users or a long tail of occasional visitors. The interviewer checks a simple window filter, distinct-day counting and a GROUP BY on an aggregate.

What the Interviewer Expects
  • Filter to the seven-day window ending on the report date inclusive
  • Count distinct active days per user
  • Group by that count to build the histogram
  • Add percent of window-active users
  • Mention what a healthy versus unhealthy shape looks like
Key Topics to Cover
L7
engagement distribution
COUNT DISTINCT
histogram
date window
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you compute L7 for every day in a month without seven self-joins?
  • How would you compare the L7 shape before and after a launch?
  • Would you include users who were inactive all week as an L0 bucket?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

daily_active(user_id, ds) has one row per user per active day, but may contain duplicates from late-arriving logs. Report date :d. Window is :d - 6 through :d....

Approach

Two levels of aggregation: per user, count distinct days in the window; then per count, count users. A window function over the second level gives the share. Doing the distinct count first matters bec...


Submit Your Answer
Markdown supported