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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Create new column using Dax to pull data from 2 table to make the new column

Hi

I have 2 tables. in which I need to create a new Column where its pulling data from both tables. Table 1 is the main table that has the key information that is related to Table 2 Primary Item Nmber. Table 1 has some part numbers that are longer in nature the Dax formula needs to look at table 2 Engineering item number to find the same part number to makethe new column 

 

Table 1

bu965_0-1639771088017.png 

Table 2 

bu965_1-1639771285916.png

Table 1 with new column

bu965_2-1639771668915.png

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

This is the correct code:

column =
VAR AA =
    LEN( [CPARTN] )
VAR BB =
    LOOKUPVALUE(
        'table 2'[Primary Item Number],
        'table 2'[Engineering item number], table[CPARTN]
    )
RETURN
    IF( AA = 7, [CPARTN], BB )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

5 REPLIES 5
VahidDM
Super User
Super User

Hi @Anonymous 

 

try this to add a new column:

 

column=

var AA= len([CPARTN])

Var BB= lookupvalue(table 2[Primary Item Number], table 2[Engineering item number], table[CPARTN])

 

return

if(AA=7,AA,BB)

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Anonymous
Not applicable

The Dax expression works fine that you gave but forgot to add that I have duplicate  values in the table so i get the error - A table of multiple values was supplied where a single value was expected . I appreciate any help. Thanks

Anonymous
Not applicable

Hi VahidDM

I was able to create the column with your information and it was what I am looking for but wanted to see where the column value is 7 that it would be equal to CPARTN number. 

 

bu965_0-1639780107461.png

 

Hi @Anonymous 

 

This is the correct code:

column =
VAR AA =
    LEN( [CPARTN] )
VAR BB =
    LOOKUPVALUE(
        'table 2'[Primary Item Number],
        'table 2'[Engineering item number], table[CPARTN]
    )
RETURN
    IF( AA = 7, [CPARTN], BB )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Anonymous
Not applicable

Hi VahidDM

The Dax expression works fine that you gave but forgot to add that I have duplicate  values in the table so i get the error - A table of multiple values was supplied where a single value was expected. I appreciate any help. Thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors