cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Aydeedglz
Helper IV
Helper IV

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors