Bird
0
0

You want to create a dbt model that calculates monthly active users (MAU) and their average spend. Which advanced pattern helps you organize this complex logic best?

hard🚀 Application Q8 of 15
dbt - Advanced Patterns
You want to create a dbt model that calculates monthly active users (MAU) and their average spend. Which advanced pattern helps you organize this complex logic best?
ACreate separate models for MAU and spend and never join them
BUse multiple CTEs: one for filtering active users, one for calculating spend, then join results
CWrite all logic in a single SELECT statement without CTEs
DHardcode monthly values instead of dynamic date filters
Step-by-Step Solution
Solution:
  1. Step 1: Understand the complexity of MAU and spend calculation

    These require filtering, aggregation, and joining data logically.
  2. Step 2: Identify the best pattern to organize this logic

    Using multiple CTEs breaks down steps clearly and allows reuse.
  3. Final Answer:

    Use multiple CTEs: one for filtering active users, one for calculating spend, then join results -> Option B
  4. Quick Check:

    Multiple CTEs organize complex logic well [OK]
Quick Trick: Break complex logic into multiple CTEs for clarity [OK]
Common Mistakes:
MISTAKES
  • Trying to write all logic in one query
  • Not joining related data
  • Hardcoding values instead of using filters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes