Posts

Showing posts with the label dbt tutorial

Macros in dbt | Data Build Tool | Jinja and macros tutorial

  oms_dbt_proj\macros\oms_common.sql {% macro to_celsius ( fahrenheit_column , decimal_places = 1 ) %}   ROUND ( ({{ fahrenheit_column }} - 32 ) * 5 / 9 , {{ decimal_places }}) {% endmacro %} {% macro generate_profit_model ( table_name ) %} SELECT   sales_date ,   SUM ( quantity_sold * unit_sell_price ) as total_revenue ,   SUM ( quantity_sold * unit_purchase_cost ) as total_cost ,   SUM ( quantity_sold * unit_sell_price ) - SUM ( quantity_sold * unit_purchase_cost ) as total_profit FROM {{ source ( 'training' , table_name ) }} GROUP BY sales_date {% endmacro %} oms_dbt_proj\models\profit_uk.sql {{ generate_profit_model ( 'sales_uk' ) }}