...

/

Solution: Daily Aggregation Macro

Solution: Daily Aggregation Macro

Get a detailed review of the solution to the “Daily Aggregation Macro” challenge.

We'll cover the following...

Solution

Let’s review the solution to the problem.

Please provide values for the following:
type
service_account
project_id
data-analysis-medium
private_key_id
2c7da4e64069d50bd44cf28567d7661395bed2a1
client_email
dbt-educative-course@data-analysis-medium.iam.gserviceaccount.com
client_id
108207116291318262825
auth_uri
https://accounts.google.com/o/oauth2/auth
token_uri
https://oauth2.googleapis.com/token
auth_provider_x509_cert_url
https://www.googleapis.com/oauth2/v1/certs
client_x509_cert_url
https://www.googleapis.com/robot/v1/metadata/x509/dbt-educative-course%40data-analysis-medium.iam.gserviceaccount.com
private_key
private_key
project_name
data-analysis-medium
dataset_name
educative
dataset_location
US
{% macro daily_count(field_to_count) %}
SELECT 
    order_date, 
    COUNT(DISTINCT {{field_to_count}} ) AS {{field_to_count}}
FROM {{ ref("orders") }}
GROUP BY order_date
{% endmacro %}
Solution code: Creating a daily_count macro

Code explanation

In the daily_count.sql file: ...