RELATEDTABLE Function
SQL Server 2012
Evaluates a table expression in a context modified by the given filters.
The following example uses the RELATEDTABLE function to create a calculated column with the Internet Sales in the Product Category table.
The following table shows the results of using the code shown here.
|
Product Category Key |
Product Category AlternateKey |
Product Category Name |
Internet Sales |
|
1 |
1 |
Bikes |
$28,318,144.65 |
|
2 |
2 |
Components |
|
|
3 |
3 |
Clothing |
$339,772.61 |
|
4 |
4 |
Accessories |
$700,759.96 |
= SUMX( RELATEDTABLE('InternetSales_USD')
, [SalesAmount_USD])
