Coding Challenge: Daily Aggregation Macro

Complete this hands-on exercise to build a macro that aggregates data daily.

We'll cover the following

Problem

We want to have different metrics at a daily level: unique customers, and unique products sold. To avoid duplicating logic, we want to store the logic in a macro and call that macro with a different argument.

Tasks

  • Build a macro in macros/daily_count.sql that takes a field as an argument, groups data by date, and counts distinct values for that field and day.

  • Then, implement that macro in two models, daily_customers.sql and daily_products.sql.

Playground

Add your solution code in the widget below.

Get hands-on with 1400+ tech skills courses.