Forum Discussion

kirbynguyen's avatar
kirbynguyen
Helper II
4 years ago
Solved

Multiple Relationships with Many to Many

I am using a identifier table to try to display the values from another table. Here are the tables:

datenamevalue
1-JanRed14
2-JanRed31
3-JanRed43
4-JanRed78
5-JanRed24
1-JanBlue65
2-JanBlue54
3-JanBlue24
4-JanBlue54
5-JanBlue24
1-JanGreen75
2-JanGreen22
3-JanGreen64
4-JanGreen43
5-JanGreen33
1-JanPurple23
2-JanPurple12
3-JanPurple55
4-JanPurple67
5-JanPurple

89

 

namename2name3
RedBluePurple
BluePurpleRed
GreenPurpleRed

 

What I'm trying to display using this example is when I select the first row on the identifier table, I want to display the values for name, name2, and name 3 from the data table. To do this, I have a main relationship (1-many) from ID[name] to Data[name], and also 2 disabled (many-many) relationships for ID[name2] to Data[name] and ID[name3] to Data[name]. I've tried creating DAX to use the relationships for name2 and name3, but it is giving the exact same values for name one.

 

The result I want for the first row (Red, Blue, Purple) is to show the Red, Blue, and Purple lines on 3 separate graphs when I selected the unique [name].

 

How do I solve this?

  • Identifier:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc8xC8MgEIbh/3JzOujdabp2KXQqXcWhELcQSiD/v6nxhK9k8eBB7tWUyF0e74UGepVpP51QHhJ5QHYVGVC4ogDGsaIC+mOnhW7zVvYRFEpNVSDVtG2Q07t6etdq97WU34yYM/YeesYBg8btz/rHzJB8butnrk9haHZ3GO2uCtXuIUK2+3ilnL8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, name = _t, value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"name", type text}, {"value", Int64.Type}}),
        #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"name"}, Reference, {"name"}, "Reference", JoinKind.LeftOuter),
        #"Expanded Reference" = Table.ExpandTableColumn(#"Merged Queries", "Reference", {"name2", "name3"}, {"name2", "name3"})
    in
        #"Expanded Reference"

    Reference:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkpNUdJRcsopTQVSAaVFBTmpSrE60WgiOmB1IHH3otTUPAyJWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [name = _t, name2 = _t, name3 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"name2", type text}, {"name3", type text}})
    in
        #"Changed Type"
    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

2 Replies

  • Identifier:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc8xC8MgEIbh/3JzOujdabp2KXQqXcWhELcQSiD/v6nxhK9k8eBB7tWUyF0e74UGepVpP51QHhJ5QHYVGVC4ogDGsaIC+mOnhW7zVvYRFEpNVSDVtG2Q07t6etdq97WU34yYM/YeesYBg8btz/rHzJB8butnrk9haHZ3GO2uCtXuIUK2+3ilnL8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, name = _t, value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"name", type text}, {"value", Int64.Type}}),
        #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"name"}, Reference, {"name"}, "Reference", JoinKind.LeftOuter),
        #"Expanded Reference" = Table.ExpandTableColumn(#"Merged Queries", "Reference", {"name2", "name3"}, {"name2", "name3"})
    in
        #"Expanded Reference"

    Reference:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkpNUdJRcsopTQVSAaVFBTmpSrE60WgiOmB1IHH3otTUPAyJWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [name = _t, name2 = _t, name3 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"name2", type text}, {"name3", type text}})
    in
        #"Changed Type"
    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi kirbynguyen ,

     

    Whether the advice given by lbendlin  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


    Looking forward to your feedback.


    Best Regards,
    Henry