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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors