How to write and test transformations
Now that we have some data, we can start using dbt to transform that data into the information that we want to deliver for reporting or our other use cases.
Writing the first dbt model
For the time being, we just have one piece of information – the content of the portfolio from ABC Bank that we have loaded in the landing table.
This, in dimensional modeling terms, is a fact, which is a table that provides quantitative information about some objects or events that we want to reason about.
To provide more value on top of the data itself, we want to calculate a few other measures for the positions and make them available to our reports.
First, we are going to calculate the profit for each position.
Let’s create a POSITION_ABC_BANK.sql
file in the models folder with this content:
SELECT * , POSITION_VALUE - COST_BASE as UNREALIZED_PROFIT FROM {{ source('abc_bank...