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
raymond
Post Patron
Post Patron

Composing Tables from many-to-many (denormalization)

Hi Community,

 

I want to compose/ merge tables and combine their values. I am looking for a method that uses calculated columns (dax) or power query. 

 

There is a simpliefied scenario: 

- Table A contains Source Data with Cost

- Table B contains User Date based upon the source Data

- A third Table A+B should be created. Look at the image example.

 

Table A:

Table ATable A

 

Table B:

Table BTable B

 

Result Table A+B

Result Table A+BResult Table A+B

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @raymond -

In Power Query, you could do the following:

  1. Group Table B by Date and Site, with SUM of User.
  2. In Table A, Merge Table B, joining on Date and Site.
  3. Expand columns to add User.
I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.
Nathan Peterson

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula in Table A will work

=CALCULATE(SUM('Table B'[User]),FILTER('Table B','Table B'[Date]=EARLIER('Table A'[Date])&&'Table B'[Source]=EARLIER('Table A'[Source])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @raymond -

In Power Query, you could do the following:

  1. Group Table B by Date and Site, with SUM of User.
  2. In Table A, Merge Table B, joining on Date and Site.
  3. Expand columns to add User.
I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.
Nathan Peterson

hi @Anonymous , thank you. That was easy. Say do you know a way to do it with a calculated column too?

Anonymous
Not applicable

@raymond - There are ways to do this, but you wouldn't want to bring a table into Power BI unless you need it there for another purpose.

One way you could do this is:

1. Create a Custom Column in Power Query on each table - concatenate the date and source.

2. Create a Relationship between the tables in Power BI - use the concatenated column for the join.

3. Create a Calculated Column like this:

Sum Of User = 
SUMX(
    RELATEDTABLE('OtherTable'),
    'OtherTable'[User]
)

 

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.