Using projection to combine data from different tables
The evaluation of an entire table (as shown in the previous recipe, Retrieving data from a single table) excludes the wider concept of projection, because the example returns all the columns from a single table. More often than not, we wish to return only a subset of columns (or perhaps even derived columns) from one or more tables. Unlike SQL, which allows projection in its syntax, DAX has no succinct projection equivalent.
Consider the following SQL statement, which selects column_a
from table_a
and column_b
from table_b
.
Select table_a.column_a, table_b.column_b From …
Using DAX, we cannot specify a projection in the same manner (as follows):
Evaluate('table_a'[column_a], 'table_b'[column_b])
If we wish to mimic this activity using DAX, we must define the table as part of the evaluate
statement. This recipe examines how to do that.
Getting ready
This recipe shows the concepts of projection by answering a common type of question (from our...