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
mhammo
Helper I
Helper I

Calculate a single column from 2 columns from different tables

Hello All,

 

I may be missing something easy so please forgive. I have attached an example file of the "source data".

 

I want to take the Contact Name from the contacts table, the Company name from the company table and merge them both into a new single column in the Sales table, called Customer.

 

The end result I want is: CustomerID, Customer, Item, Amount Is this possible with DAX?

 

File: pbix

 

Mike

1 REPLY 1
MFelix
Super User
Super User

Hi @mhammo,

 

Not really sure if I understand your question since the fields on your data based have different names.

 

But if ContactID = CustomerID then you just have to make a relationship between Contacts and Sales tables by this two fields and everything will be working as you need.

 

However since the contactID is smaller than the customerID list the name will be missing on some rows.

 

If you want to have asingle table that combine both them just add the following dax to create a new table:

Table =
UNION (
    SELECTCOLUMNS ( Company; "ID"; Company[Companyid]; "Name"; Company[Company] );
    SELECTCOLUMNS ( Contacts; "ID"; Contacts[Contactid]; "Name"; Contacts[Name] )
)

Then relate this table with your sales table and create the visual.

 

See attach PBIX with the changes.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.