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
AiolosZhao
Memorable Member
Memorable Member

With using Many-to-Many relationship, when I use measure or sum the amount, some value don't show

Hi all, 

I have two tables:

T1:

TYPEKEYNAMEAMOUNT
TYPE1AAAA12
TYPE2AAAA12
TYPE1BBBB13
TYPE2CCCC14
TYPE1DDDD11

 

T2:

KEYCUSTOMER
AAAA2
AAAA3
BBBB2
CCCC2

 

And the column KEY is the relationship key between these two tables; it's a many-to-many relationship.

 

And when I create a table in my power bi:

With using Many-to-Many relationship, when I use measure or sum the amount, some value don't show1.PNG

 

Question 1: You can see the AMOUNT of D1 is missing. Why?

Question 2: After I change the column sort like the below image, the AMOUNT is also missing, but after I change the format of AMOUNT to "Don't Summarize", then the AMOUNT show up. Why?

 

With using Many-to-Many relationship, when I use measure or sum the amount, some value don't show2.PNG

 

Thanks in advance.

Aiolos Zhao

 




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

Proud to be a Super User!




1 ACCEPTED SOLUTION

I have given you some advice about data modeling - that advice is correct.  I have taken a closer look at your sample data.  What you need to understand about Power BI is that the rows in the tables will filter the other tables in the model (in the direction of the filter arrows only).

 

Back to your questions.

1. The reason the value D1 is missing is due to filtering.  When you place Name and Customer onto the rows in the table, you are putting filters on both of those columns.  In otherwords, you are saying "Show all the data where Name = D1 and Customer = Blank.  There is no such data in your model, and that is why it is not showing.  If you remove the Customer from the visual, then you will see the value.

 

2. When you say "don't summarise", you are changing the behaviour of the model.  You are now filtering on all 3 columns.  Power BI shows the list of values for all 3 columns.

 

The test data you have shared is not very descriptive, so it is not clear what it is or how it should be used.  Power BI is a semantic data modelling tool.  It is designed to accept entitiy based dimension tables and also fact tables (dimensional modelling).    I can't advise you on how to set up your data because there is no context in the table names.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

11 REPLIES 11
AiolosZhao
Memorable Member
Memorable Member

Or any documentation about this so I can know more information?

 

Thanks.

Aiolos Zhao





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

Proud to be a Super User!




Your new table should also have the Name included.  You should always use columns from this new table in your visual (the text ones).  You can then use the numeric columns from any table.

 

It is not clear in your image which table the Key column has come from.  My guess is it is not the new table. 


You can read my artile her for more information. https://exceleratorbi.com.au/the-optimal-shape-for-power-pivot-data/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

And I have read the documentation you shared with me, thanks.

 

But I think that's talk about the star schema, and I know the cons and pros for star schema, snow schema, etc.

 

I didn't find an explanation of my two questions.

 

Aiolos Zhao





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

Proud to be a Super User!




Hi @MattAllington ,

 

Thanks for your reply, as you can see, I have two tables like below:

T1:

TYPEKEYNAMEAMOUNT
TYPE1AAAA12
TYPE2AAAA12
TYPE1BBBB13
TYPE2CCCC14
TYPE1DDDD11

 

T2:

KEYCUSTOMER
AAAA2
AAAA3
BBBB2
CCCC2

 

For Power BI, what's the best way to make below table:

NAMEAMOUNTCUSTOMER
A12A2
A12A3
B13B2
C14C2
D11 

 

Could you please show and tell me?

Thanks in advance

Aiolos Zhao





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

Proud to be a Super User!




In the visual you posted above, after you created the third table, which key are you using in the visual?  It should be the key column from the new table.  Is it?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Do you mean the T3?

The KEY column in T3 is created by manually, just merge all values of KEY from T1 and T2.

 

You can also forget the T3 I created, just using T1 and T2, I have shown you the table that I want.

 

What kind of operations should I do now?

 

Aiolos Zhao





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

Proud to be a Super User!




I am trying to help you here.  You need the other table (you called it T3).  Create the table as I described and add the other columns that are part of the key too (customer, name etc).


Join the 3 tables as I described

Then use the Key column from T3 and not from the other tables.  

 

This is how you do it.  If you can't work it out, then post a link to your sample workbook here and I will do it for you.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Could you please show me what the T3 should look like using below T1/T2?

T1:

TYPEKEYNAMEAMOUNT
TYPE1AAAA12
TYPE2AAAA12
TYPE1BBBB13
TYPE2CCCC14
TYPE1DDDD11

 

T2:

KEYCUSTOMER
AAAA2
AAAA3
BBBB2
CCCC2




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

Proud to be a Super User!




I have given you some advice about data modeling - that advice is correct.  I have taken a closer look at your sample data.  What you need to understand about Power BI is that the rows in the tables will filter the other tables in the model (in the direction of the filter arrows only).

 

Back to your questions.

1. The reason the value D1 is missing is due to filtering.  When you place Name and Customer onto the rows in the table, you are putting filters on both of those columns.  In otherwords, you are saying "Show all the data where Name = D1 and Customer = Blank.  There is no such data in your model, and that is why it is not showing.  If you remove the Customer from the visual, then you will see the value.

 

2. When you say "don't summarise", you are changing the behaviour of the model.  You are now filtering on all 3 columns.  Power BI shows the list of values for all 3 columns.

 

The test data you have shared is not very descriptive, so it is not clear what it is or how it should be used.  Power BI is a semantic data modelling tool.  It is designed to accept entitiy based dimension tables and also fact tables (dimensional modelling).    I can't advise you on how to set up your data because there is no context in the table names.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

This is a complex topic. The simple answer is “don’t use many to many unless you know when it works and when it doesn’t”. I suggest you create a new table with a distinct list of all the keys. Join both tables to this new table (1 to many) and use the new table in your visuals.  This is how power BI is designed to work. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi @MattAllington ,

 

Thanks for the reply.

Do you mean I need to create a new table like below:

T3:

KEY
AAA
BBB
CCC
DDD

 

Then I create relationships like below:

With using Many-to-Many relationship, when I use measure or sum the amount, some value don't show3.PNG

 

But the AMOUNT is also missing in my table:

With using Many-to-Many relationship, when I use measure or sum the amount, some value don't show4.PNG

 

Or do you mean I need to use "merge query" in edit query?

 

I think if my data is too large, the merge query would cost too much time.

 

Aiolos Zhao





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

Proud to be a Super 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.