0
0
dbtdata~15 mins

Why models are the core of dbt - See It in Action

Choose your learning style9 modes available
Understanding Why Models Are the Core of dbt
📖 Scenario: Imagine you work in a company that collects sales data every day. You want to organize this data to answer questions like "Which products sell best?" or "How much revenue did we make last month?". dbt helps you do this by letting you create models that transform raw data into useful tables.
🎯 Goal: You will build a simple example to see why models are the heart of dbt. You will create a data structure for sales, set a filter condition, write a model to select important data, and finally display the result.
📋 What You'll Learn
Create a dictionary with sales data
Add a filter threshold for minimum sales
Write a model to select products with sales above the threshold
Print the filtered sales data
💡 Why This Matters
🌍 Real World
In real companies, raw data is messy and large. Models help clean and organize data so teams can answer important questions quickly.
💼 Career
Data analysts and engineers use dbt models daily to build reliable data pipelines that power dashboards and reports.
Progress0 / 4 steps
1
Create the sales data dictionary
Create a dictionary called sales_data with these exact entries: 'apple': 100, 'banana': 50, 'cherry': 75, 'date': 30, 'elderberry': 90.
dbt
Need a hint?

Use curly braces {} to create a dictionary. Separate keys and values with colons, and pairs with commas.

2
Set the minimum sales threshold
Create a variable called min_sales and set it to 60.
dbt
Need a hint?

Just assign the number 60 to the variable min_sales.

3
Write the model to filter sales data
Create a new dictionary called filtered_sales using a dictionary comprehension. Include only items from sales_data where the sales value is greater than or equal to min_sales. Use product and sales as the loop variables.
dbt
Need a hint?

Use a dictionary comprehension with {key: value for key, value in dict.items() if condition}.

4
Print the filtered sales data
Write a print statement to display the filtered_sales dictionary.
dbt
Need a hint?

Use print(filtered_sales) to show the result.