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
brs09j
Helper II
Helper II

Getting an amount when the two tables don't have a relationship

So I have tables A, B and C

 

Table A is the fact table and table B is related to table A in a One-to-many relationship.

 

Table B is related to table C in a One-to-many relationship as well.

 

Table A and Table C have no direct relationship. However, they are both related to table B.

 

I want the amount from the cost column in table A to go under the product description column from table C in a matrix.

 

I wrote the following below but I'm not sure it is correct or even needed. Do I just need to switch my relationship filtering settings? Joining table A to table C would be many to many. Is that even allowed in Power BI?

 

Sales Amount =
CALCULATE (
    SUMX ( Table_A, Table_A[Cost] * Table_A[Quantity] ), 
    Table_C
)

 

 

Thanks.

 

1 ACCEPTED SOLUTION

It's going to be dependent on the cross-filter directions of your relationships. If Table A filters your bridge table, Table B and Table B filters Table C then you have a many-to-many relationship in your case or vice versa. I'd have to see the relationship map.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

In theory, you should not need that calculation since it is a simple SUM essentially. You can have many-to-many in Power BI with a bridge table as you have in your model. I'd have to model out what you are doing to be certain, can you supply sample data?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler

 

I'm sorry, I don't have any generic sample data. You say that it is a normal SUM since the amount is already stored on Table A and no calculation is needed. That part makes sense to me, but since there is no relationship I can't use RELATED or RELATEDTABLE.

@Greg_Deckler

 

To check,

 

I created a calculated column on table B

 

Transaction Amount = 
   SUMX (
        RELATEDTABLE ( Table_A) , Table_A[Expenses] * 1)

 

I get unique values here for my new column but when I drag the new field into the matrix I get the same number repeating

@Greg_Deckler

 

I made the expenses a row in the matrix visualization instead of a value and that gave me the unique numbers I needed. Any idea why it works that way?

 

Thanks.

It's going to be dependent on the cross-filter directions of your relationships. If Table A filters your bridge table, Table B and Table B filters Table C then you have a many-to-many relationship in your case or vice versa. I'd have to see the relationship map.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.