<!-- https://learnsql.cpetoday.com/functions/dax/related -->
# RELATED

Language: DAX
Category: Relationships and lookup
Syntax: RELATED(<column>)
Summary: Brings a value from the one side of a relationship into the current row of the many side.
Returns: A single value from the related row.
Level: Beginner
Related: RELATEDTABLE, LOOKUPVALUE, CALCULATE, SUMX, USERELATIONSHIP, TREATAS

## What it does
RELATED follows an existing relationship from the many side (the fact table, such as Sales) to the one side (a dimension, such as Product), and returns one column value. Use it in a calculated column on Sales to add the product category to each line. Use it inside an iterator over Sales to pull a product attribute such as unit cost. A relationship must already exist.

## Syntax and arguments
- **column**: a column on the one side, such as `Product[ProductCategory]`. The relationship must already exist and be active.
- The function returns one value for each row. If the one side has no match, the result is blank.

## Example
Add the product category to each sales line, as a calculated column on Sales.

```dax
Product Category =
RELATED ( Product[ProductCategory] )
```

Each row in Sales gets the category of its product, found through the product key. Because it is a calculated column, the value is stored when the model refreshes, and the column can then be used for slicing and grouping.

## Example: a second use
A standard cost for the quantity sold, using each product's unit cost instead of the cost recorded on each line.

```dax
Standard Cost =
SUMX (
    Sales,
    Sales[SalesQuantity] * RELATED ( Product[UnitCost] )
)
```

For each sales line, the quantity is multiplied by the product's unit cost from the Product table. The total is the cost at list unit cost, which can differ from the TotalCost recorded on each line. A difference like that is a useful review point.

## Things to watch
- RELATED goes from the many side to the one side only. To go the other way (dimension to fact), use `RELATEDTABLE` or a filter.
- It needs a row context, such as a calculated column or an iterator over the fact table. In a plain measure there is no current sales row.
- An inactive relationship is not used by RELATED. Use `USERELATIONSHIP` for that case.
- For a one-off lookup that has no relationship in the model, see `LOOKUPVALUE`.
- Blank results usually mean the key did not match, so check the keys.

## In business terms
Adding product category, store country or customer segment to transaction lines so reports can group by them. It is also used to bring a standard cost, tax rate or account classification into a ledger detail table.
