Forum Discussion
Excel Power Query/Data Model with Many to Many Relationship and Text Values in Pivot Table
- Jul 27, 2023
dtbsmith
First, Excel data model doesn't support natively many-to-many or one-to-one relationships.Secondly, creating relationships first thing to do is to hide fields on many side from the client tool and don't use them in PivotTable (just best practice).
Third, when we go from one side to many and next from many to one that doesn't work, result as you have. I'd use virtual relationship here
DV := IF ( ISFILTERED ( Table3[Type] ) && [Count] <> BLANK (), CALCULATE ( CONCATENATEX ( Table3, Table3[Description] ), TREATAS ( VALUES ( Table3[Type] ), Table2[Type] ) ), BLANK () )
PivotTable with this measure is
As a comment, I'd use more meaningful names for the tables rather than Table1, Table2, etc.
Please check in attached file.
dtbsmith
First, Excel data model doesn't support natively many-to-many or one-to-one relationships.
Secondly, creating relationships first thing to do is to hide fields on many side from the client tool and don't use them in PivotTable (just best practice).
Third, when we go from one side to many and next from many to one that doesn't work, result as you have. I'd use virtual relationship here
DV :=
IF (
ISFILTERED ( Table3[Type] )
&& [Count] <> BLANK (),
CALCULATE (
CONCATENATEX ( Table3, Table3[Description] ),
TREATAS ( VALUES ( Table3[Type] ), Table2[Type] )
),
BLANK ()
)
PivotTable with this measure is
As a comment, I'd use more meaningful names for the tables rather than Table1, Table2, etc.
Please check in attached file.
In your mark up you show the relationship between Table 2 and 3 to be removed - is this because the formula that you drafted looks at table 3 rather than relies on a relationship between the two tables?
- SergeiBaklanJul 27, 2023Diamond Contributor
Sorry for the confusing, we need that physical relationship for the [COUNT] measure, perhaps something else. I meant we don't need it for the description measure.
More about relationships