Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Aydeedglz
Helper V
Helper V

DAX CODE BRINGING COLUMNS FROM TWO DIFFERENT TABLES

Hi, I am trying to create a DAX Code where I can join columns from two tables. I have a third one but is a measure so is easy to bring, but I am not able to bring information from table 2. 

 

They are related in my data source by a column, but I am not using it in this code. This code shows me an error when I add the bolt part 

 

Table 1

Table 2 

Table 3 - Measure Table

 

EVALUATE
Filter(TABLE1,
TABLE1[COLUMNFILTER1] = "Open" &&
TABLE1[COLUMNFILTER2] = "Yes" &&
TABLE1[COLUMNFILTER3] = "No" &&
TABLE1[COLUMNFILTER4] = "Yes" &&
TABLE1[COLUMNFILTER5] = "No")
 
EVALUATE
ADDCOLUMNS(
SUMMARIZE(
TABLE1,
TABLE1[COLUMNA],
TABLE1[COLUMNB],
TABLE1[COLUMNC],
TABLE1[COLUMND],
TABLE1[COLUMNE],
TABLE1[COLUMNF],
TABLE1[COLUMNG],
TABLE1[COLUMNH],
TABLE1[COLUMNI],
"TABLE2", RELATED (TABLE2[Column2]),
"COLUMNMEASURE", [COLUMNMEASUREVALUE])

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Aydeedglz 

what kind of relationship? What is the filter direction?

Is Table 2 to Table 1 based on 

 

"Column 1" from table 2

"Random column" form table 1 

 

I dont need any of the columns as a result in my table

Hi @Aydeedglz ,

 

Please try:

 

EVALUATE
ADDCOLUMNS(
    FILTER(
        TABLE1,
        TABLE1[COLUMNFILTER1] = "Open" &&
        TABLE1[COLUMNFILTER2] = "Yes" &&
        TABLE1[COLUMNFILTER3] = "No" &&
        TABLE1[COLUMNFILTER4] = "Yes" &&
        TABLE1[COLUMNFILTER5] = "No"
    ),
    "TABLE2", RELATED(TABLE2[Column2]),
    "COLUMNMEASURE", [COLUMNMEASUREVALUE]
)

 

Note that for the RELATED function to work, there must be a relationship between the two tables based on a common column. In your case, the relationship is based on "Column 1" from Table 2 and "Random column" from Table 1.

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

@Aydeedglz 
Then please try

EVALUATE
ADDCOLUMNS (
    SUMMARIZE (
        TABLE1,
        TABLE1[COLUMNA],
        TABLE1[COLUMNB],
        TABLE1[COLUMNC],
        TABLE1[COLUMND],
        TABLE1[COLUMNE],
        TABLE1[COLUMNF],
        TABLE1[COLUMNG],
        TABLE1[COLUMNH],
        TABLE1[COLUMNI],
        TABLE2[Column2]
    ),
    "COLUMNMEASURE", [COLUMNMEASUREVALUE]
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.