# Setting up derived attributes

Derived attributes are attributes whose data is "derived" from other attributes. For example, lets assume that the `OrderDetails` entity contains the attributes `Quantity` and `UnitPrice` but does not contain the attribute `TotalPrice`. To gain better insight into the annual sales figures, the organization would like to add the `TotalPrice` attribute to the model and derive its data from the `Quantity` and `UnitPrice` attributes.

Assuming that the Northwind sample database is the model’s source, this could easily be done as follows:

1. Add the `TotalPrice` attribute domain to the model as described in [Managing attributes](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Model/manage_attributes.htm).

2. After finalizing the model, create the data warehouse tables as described in [Creating the data warehouse tables](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Data%20Warehouse/create_data_warehouse_tables.htm).

3. Click the `OrderDetails` mapping as described in [Editing column mappings](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Data%20Warehouse/edit_column_mappings.htm).

   Note that the `TotalPrice` attribute has no mapping as it was added after the Northwind source was discovered:

   ![Example Order Details mapping in data warehouse columns, with TotalPrice attribute selected and fx function icon visible to the right](https://help.qlik.com/en-US/compose/December2024/Content/Resources/Images/ComposeForDataWarehouses/totalprice.png)

4. Open the Expression Builder by clicking the fx icon to the right of the `TotalPrice` column name. Then, in the Expression Builder, add the `Quantity` and `UnitPrice` columns to create the following expression:

   `Quantity*UnitPrice`

   For more information on creating expressions, see [Creating expressions](https://help.qlik.com/en-US/compose/December2024/Content/ComposeDWDL/Main/DW/Model/create_expressions.htm).

5. Click OK to close the Expression Builder and save the expression.

   The `Quantity` and `UnitPrice` landing zone columns are now mapped to the `TotalPrice` data warehouse column. Notice that the mapping lines are gray, indicating that the mapping is the result of an expression.

   ![Example Order Details mapping in data warehouse columns, with gray mapping lines connecting the TotalPrice attribute to the landing zone columns on the left side](https://help.qlik.com/en-US/compose/December2024/Content/Resources/Images/ComposeForDataWarehouses/expression_mapping.png)

   Hovering the mouse cursor over the gray lines highlights the derived column (`TotalPrice`) and the columns from which its data is derived (`Quantity` and `UnitPrice`).

   ![Example Order Details mapping, with the mouse cursor positioned over the gray lines and all elements linked to the TotalPrice attribute highlighted](https://help.qlik.com/en-US/compose/December2024/Content/Resources/Images/ComposeForDataWarehouses/hover_mapping.png)